Request cookbook
Each page in this cookbook takes one question you would ask of the TPC-DS model, writes it as a query spec (and as a zsql sql --expr line when the shorthand can say it), and shows the single SQL statement the planner returns. The SQL is quoted from the engine’s own tests, unchanged. Where a variation has no test to quote, the page shows the request and describes the shape of the statement instead of inventing one. All requests go to POST https://app.0sql.io/projects/tpcds/branches/main/sql with Authorization: Bearer zqk_.... Fields are referenced by name or uid: Web Net Paid (ws_net_paid, on web_sales), Net Paid (net_paid, on store_sales), Category, Product Name, Date, Customer Id.
| Page | Feature | What the SQL shows |
|---|---|---|
| Cross-fact blend | measures from two fact tables in one row | one aggregation CTE per fact, FULL OUTER JOIN on the conformed key, COALESCE |
| Complex measures | calculations with [Name]@m, [Alias], CASE and windows; compound measures in YAML | arithmetic at the merge, re-aggregation over a subquery |
| Cohorts and segments | segments at query level and measure level, expanding pairs | a seg… CTE INNER JOINed on the key, inside one measure’s CTE or around the whole query |
| Period over period | temporalize with month_over_month, percent_change | a shifted-date aggregation CTE, HAVING kept inside it |
| Share and windows | contribute, window running and moving functions | a CROSS JOIN to a total CTE, OVER (PARTITION BY … ORDER BY …) |
| Filters and top-n | flat lists, and/or trees, lists, dates, LIKE, measure filters, top_n | WHERE versus HAVING, a ranking CTE with LIMIT |
| Security context | context with groups and tags against filter_data and mask_data policies | WHERE LOWER(dim) IN (…), CASE WHEN … ELSE NULL END |
| Level of detail | exclusion and inclusion measures from the model, requested beside plain measures | an extra aggregation at a coarser or finer grain joined back |
The pages reference each other but stand alone. If you have not seen a spec before, The query spec lists every key.