Back to ClickHouse in Google Sheets
SheetXAI logo
ClickHouse logo
ClickHouse · Google Sheets Guide

Query Multiple ClickHouse Tables Into a Single Google Sheet Report

2026-05-14
5 min read

The Scenario

Your analytics engineering team is three weeks into a new reporting cadence. The ask from the VP of Finance: one Excel-style workbook — but in Google Sheets — showing Q1 revenue broken down two ways: by product category in one tab, by country in another, with a combined top-10 summary in a third tab.

The data lives in two separate ClickHouse tables. You know how to query both. What you don't want to do is run two queries, export two CSVs, import them into two tabs, and then build the summary tab by hand — especially since this report will run again at end of Q2.

The bad version:

  • Query the orders table for revenue by product_category, export CSV, import to Sheet1.
  • Query the same table filtered by country, export a second CSV, import to Sheet2.
  • Write the combined top-10 summary in Sheet3 by hand, pulling figures from the other two tabs with IMPORTRANGE formulas that will break the moment someone renames a column.

That's four separate operations, and none of them talk to each other. The summary tab is fragile from the moment you build it.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads the workbook structure, connects to ClickHouse, and executes multi-query workflows across multiple tabs from a single instruction.

Query my ClickHouse 'orders' table for total revenue and order count grouped by product_category for Q1 2025 and write the results into Sheet1 starting at A1 with headers.

Then, for the combined layout:

Query my ClickHouse 'orders' table for revenue by country for Q1 2025 and write into Sheet2, then create a combined summary in Sheet3 showing top-10 categories and top-10 countries side by side.

What You Get

  • Sheet1: product_category, total_revenue, order_count — with header row, one row per category.
  • Sheet2: country, total_revenue — sorted descending by revenue.
  • Sheet3: a side-by-side summary table with the top 10 in each dimension, labeled and ready for presentation.
  • No import wizards. No intermediate CSVs. No manually typed formulas in the summary tab.

What If the Data Is Not Quite Ready

The 'orders' table has multiple currencies and you need USD only

Query my ClickHouse 'orders' table for total revenue in USD only (where currency = 'USD') grouped by product_category for Q1 2025 and write results into Sheet1 starting at A1 with headers.

One of the country names is stored inconsistently — 'US', 'USA', and 'United States' all appear

Query ClickHouse for revenue by country for Q1 2025. Before writing to Sheet2, normalize 'US' and 'USA' to 'United States' in the country column. Then write the consolidated results with headers.

The product categories have changed since Q4 and you want to compare Q1 2025 to Q1 2024 side by side

Query my ClickHouse 'orders' table for revenue by product_category for Q1 2025 and for Q1 2024. Write Q1 2025 revenue in column B and Q1 2024 revenue in column C, with product_category in column A — match the categories across both periods.

End-to-end: pull, normalize, summarize, and flag any category with less than $1,000 in revenue

Query ClickHouse for Q1 2025 revenue by product_category. Write results to Sheet1. In Sheet3, create a top-10 summary and add a column flagging any category below $1,000 total revenue as 'Low volume' — use 'Active' for everything else.

When the cleanup and the analysis and the summary are all part of one instruction, you skip the three-step process entirely.

Try It

Get the 7-day free trial of SheetXAI and open the Google Sheet where your Q1 reporting lives, then ask it to pull both revenue cuts from ClickHouse and populate the tabs. See also the parameterized query spoke or the full ClickHouse overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more