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.

PageFeatureWhat the SQL shows
Cross-fact blendmeasures from two fact tables in one rowone aggregation CTE per fact, FULL OUTER JOIN on the conformed key, COALESCE
Complex measurescalculations with [Name]@m, [Alias], CASE and windows; compound measures in YAMLarithmetic at the merge, re-aggregation over a subquery
Cohorts and segmentssegments at query level and measure level, expanding pairsa seg… CTE INNER JOINed on the key, inside one measure’s CTE or around the whole query
Period over periodtemporalize with month_over_month, percent_changea shifted-date aggregation CTE, HAVING kept inside it
Share and windowscontribute, window running and moving functionsa CROSS JOIN to a total CTE, OVER (PARTITION BY … ORDER BY …)
Filters and top-nflat lists, and/or trees, lists, dates, LIKE, measure filters, top_nWHERE versus HAVING, a ranking CTE with LIMIT
Security contextcontext with groups and tags against filter_data and mask_data policiesWHERE LOWER(dim) IN (…), CASE WHEN … ELSE NULL END
Level of detailexclusion and inclusion measures from the model, requested beside plain measuresan 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.