Pivoting, Unpivoting and FILTER: practice questions
400 questions in four levels, all on RetailMart, the practice database of this course. Write every query yourself, get it wrong, read the error, fix it. That is how it sticks.
Answers are coming soon. Post your query in the WhatsApp Community or Discord and we will check it together.
Easy 100 questions Medium 100 questions Hard 100 questions Crazy 100 questions
Core syntax, applied directly
CONCEPTUAL Q1 What does "pivoting" mean (rows -> columns)? Q2 What does the FILTER (WHERE ...) clause do on an aggregate? Q3 Rewrite SUM(CASE WHEN c THEN x END) as SUM(x) FILTER (WHERE c). Q4 Why is FILTER cleaner/clearer than CASE-inside-aggregate? Q5 What does "conditional aggregation" mean? Q6 Why must pivot columns be a known/fixed set in plain SQL? Q7 How is dynamic pivot done (crosstab/tablefunc) - and why it needs an extension? Q8 What does "unpivoting" mean (columns -> rows)? Q9 How does UNION ALL unpivot a wide table into long format? Q10 When should you pivot in SQL vs leave it to the BI tool? Q11 Why does COUNT(*) FILTER (WHERE c) count only matching rows? Q12 What does a pivot's GROUP BY key become (the row label)? Q13 How do you get a percent-of-row-total in a pivot? Q14 Why might pivoted NULLs need COALESCE(..., 0)? Q15 Can you mix FILTER with GROUP BY? (yes - show the shape) Q16 Difference between SUM(x) FILTER (WHERE c) and SUM(x) WHERE c. Q17 What is unnest() and how can it help unpivot arrays? Q18 Why is a "category x month" matrix a classic pivot? Q19 How many output columns does a pivot of N categories produce? Q20 What's the risk of pivoting a high-cardinality column? Q21 How do you pivot a count vs a sum? Q22 Why is FILTER evaluated per aggregate (independent conditions)? Q23 How do you label unpivoted rows with the source column name? Q24 When is GROUPING SETS/ROLLUP a better fit than a manual pivot? Q25 Name two analyst reports that are pivots and two that are unpivots. FILTER CLAUSE Q26 Count of Delivered vs Cancelled orders using two FILTERed COUNTs. Q27 Revenue from Delivered orders only via SUM(net_total) FILTER. Q28 Per store: count of each order_status in separate FILTERed columns. Q29 Per customer: count of orders and count of Returned orders (FILTER). Q30 Per product: count of 5-star vs 1-star reviews (FILTER). Q31 Per agent: open vs resolved ticket counts (FILTER). Q32 Per region: total revenue and revenue from Gold/Platinum customers (FILTER). Q33 Per month: revenue and order count (FILTER by date range). Q34 Count of customers with vs without a phone (FILTER IS NULL). Q35 Per brand: count of products above vs below Rs5000 (FILTER). Q36 Per store: revenue this year vs last year (two FILTERs). Q37 Per courier: on-time vs late delivery counts (FILTER on day diff). Q38 Per department: count of high earners (salary>50000) via FILTER. Q39 Per platform: spend in Q1 vs Q2 (FILTER by date). Q40 Per customer: count of orders in each tier of net_total (3 FILTERs). Q41 % of orders Delivered = COUNT FILTER / COUNT(*). Q42 Per category: revenue and units (FILTER not needed) plus returned units (FILTER). Q43 Per region: count of stores opened before vs after 2023 (FILTER). Q44 Per product: avg rating and count of negative reviews (FILTER). Q45 Per store: weekday vs weekend revenue (FILTER on DOW). Q46 Count of payments by each payment_mode using FILTER. Q47 Per agent: calls under 60s vs over 300s (FILTER). Q48 Per customer: spend on Delivered vs spend on Returned (FILTER). Q49 Per month: new customers (FILTER by registration month). Q50 Combine FILTER columns into one summary row per store. CASE-BASED PIVOT Q51 Revenue by month with one column per payment_mode (FILTER pivot). Q52 Order count by region with one column per status. Q53 Per brand: count of products in price bands (value/mid/premium) as columns. Q54 Per store: revenue per quarter (Q1..Q4 columns). Q55 Per category: units sold per month (Jan..Dec columns) for one year. Q56 Per agent: ticket counts per priority (Critical/High/Medium/Low columns). Q57 Per region: customer counts per tier (Bronze..Platinum columns). Q58 Per product: review counts per rating (1..5 columns). Q59 Per courier: shipment counts per status as columns. Q60 Per department: headcount per role as columns. Q61 Per store: order counts per weekday (Mon..Sun columns). Q62 Per platform: spend per quarter as columns. Q63 Revenue per region x payment_mode matrix (region rows, mode columns). Q64 Per month: counts of each order_status as columns. Q65 Per brand: revenue per tier-of-customer as columns. Q66 Per warehouse: stock per category as columns (via product->brand). Q67 Per customer cohort (reg year): order counts per following year. Q68 Per store: this-year vs last-year revenue as two columns. Q69 Per category: returned vs delivered units as columns. Q70 Pivot with COALESCE to show 0 instead of NULL in empty cells. Q71 Per region: avg order value per quarter as columns. Q72 Per product: units in each season (spring/summer/...) as columns. Q73 Per agent: avg resolution hours per priority as columns. Q74 Per store: count of orders per net_total band as columns + row total. Q75 Build a clean "status x month" pivot for the ops team. UNPIVOT & PERCENT-OF-ROW Q76 Unpivot a 4-quarter KPI (one row, 4 cols) into 4 rows via UNION ALL. Q77 Unpivot revenue_summary-style columns into (metric, value) rows. Q78 Unpivot pay_slip components (basic, hra, pf, tax...) into long format. Q79 Unpivot a region's Q1..Q4 revenue into (quarter, revenue). Q80 Unpivot email_clicks (sent, opened, clicked) into (stage, count). Q81 Unpivot a product's price and cost_price into (kind, amount). Q82 Unpivot order totals (gross, discount, net) into rows. Q83 Pivot then add a percent-of-row-total column per status. Q84 Per region status-pivot with each status as % of the region's orders. Q85 Pivot revenue by payment_mode with a row total and per-mode %. Q86 Unpivot a wide "monthly_kpis" mock (use revenue_summary) to long. Q87 Unpivot using unnest over an ARRAY of values. Q88 Unpivot shipment date columns (shipped, delivered) into events. Q89 Percent-of-row pivot: brand price-band counts as % of brand total. Q90 Unpivot a customer's contact fields (email, phone) into (channel, value). Q91 Pivot orders-by-week-by-status, then % per status within each week. Q92 Unpivot tax_brackets columns into long format. Q93 Percent-of-column-total in a region x status pivot. Q94 Unpivot a wide quarterly sales row into a tidy long table. Q95 Pivot tier counts per region and show each tier's % of region. Q96 Unpivot then re-pivot (round-trip) to verify equivalence. Q97 Build a long-format metric table from several aggregate columns. Q98 Pivot with both row totals and column totals (manual margins). Q99 Note when to use crosstab() (tablefunc, practice) for dynamic columns. Q100 Build a category x quarter revenue matrix with row & column totals. Combined ideas, multi-step thinking
CONCEPTUAL Q1 Why does a two-dimensional pivot need GROUP BY on the row key only? Q2 How to add a row total to a pivot (extra SUM without FILTER). Q3 How to add a grand total / column total (UNION or GROUPING SETS). Q4 Percent-of-row: divide each cell by the row's total. Q5 Percent-of-column: divide each cell by a window/subquery column total. Q6 Why FILTER conditions are independent per aggregate. Q7 How to pivot a count and a sum in the same query. Q8 When to COALESCE pivot cells to 0. Q9 Unpivot with UNION ALL: structure and the label column. Q10 Unpivot with unnest over parallel ARRAYs of names/values. Q11 Why dynamic pivot (unknown categories) needs crosstab or app code. Q12 GROUPING SETS vs manual pivot for subtotals. Q13 Pivot then compute a derived ratio column (e.g. return rate). Q14 Why high-cardinality pivots are usually a BI-tool job. Q15 Round-trip: pivot then unpivot should recover the long form. Q16 Conditional aggregation with AVG FILTER vs SUM/COUNT FILTER. Q17 How to pivot booleans (bool_or/bool_and) into yes/no columns. Q18 Pivoting dates into period buckets (month/quarter) columns. Q19 Why pivot output column names must be static identifiers. Q20 How to keep a pivot stable when a category has zero rows. Q21 Difference between unpivot via UNION ALL vs via a VALUES + JOIN. Q22 Percent-of-grand-total in a 2-D matrix. Q23 Adding both row % and column % to the same matrix. Q24 When jsonb_object_agg gives a "pivot-like" dynamic result (concept; JSON is Topic 24). Q25 A checklist for building a correct pivot report. MULTI-DIMENSIONAL PIVOTS Q26 Region (rows) x order_status (columns) order-count matrix. Q27 Month (rows) x payment_mode (columns) revenue matrix. Q28 Brand (rows) x price-band (columns) product-count matrix. Q29 Store (rows) x quarter (columns) revenue matrix. Q30 Category (rows) x month (columns) units matrix (one year). Q31 Agent (rows) x priority (columns) ticket-count matrix. Q32 Region (rows) x tier (columns) customer-count matrix. Q33 Product (rows) x rating (columns) review-count matrix. Q34 Courier (rows) x on-time/late (columns) shipment matrix. Q35 Department (rows) x role (columns) headcount matrix. Q36 Store (rows) x weekday (columns) revenue matrix. Q37 Region (rows) x payment_mode (columns) revenue + row total. Q38 Brand (rows) x customer-tier (columns) revenue matrix. Q39 Category (rows) x returned/delivered (columns) units matrix. Q40 Month (rows) x status (columns) order-count + grand total row. Q41 Warehouse (rows) x category (columns) stock matrix. Q42 Cohort-year (rows) x following-year (columns) order-count matrix. Q43 Platform (rows) x quarter (columns) spend matrix. Q44 Region (rows) x season (columns) revenue matrix. Q45 Store (rows) x net_total-band (columns) order-count matrix. Q46 City (rows) x tier (columns) customer-count matrix (via addresses). Q47 Product (rows) x month (columns) revenue with a row total. Q48 Agent (rows) x status (columns) avg-resolution-hours matrix. Q49 Region x status matrix with both counts and revenue (interleaved). Q50 Build a category x quarter revenue matrix with row & column totals. PERCENT-OF-TOTAL PIVOTS Q51 Region x status order-count with each cell as % of the region's total. Q52 Month x payment_mode revenue with each cell as % of the month. Q53 Brand price-band counts as % of brand total. Q54 Store quarter revenue as % of the store's year. Q55 Category month units as % of the category's annual units. Q56 Agent priority counts as % of the agent's tickets. Q57 Region tier counts as % of the region's customers. Q58 Product rating counts as % of the product's reviews. Q59 Courier on-time % per courier (FILTER ratio). Q60 Department role headcount as % of department. Q61 Store weekday revenue as % of the store's week. Q62 Region status counts as % of the GRAND total (column-total denominator). Q63 Brand tier revenue as % of brand total. Q64 Category returned units as % of category delivered units (return rate). Q65 Month status counts as % of all orders that month AND all-time. Q66 Warehouse category stock as % of warehouse total. Q67 Cohort following-year orders as % of cohort size (retention-ish). Q68 Platform quarter spend as % of platform total. Q69 Region season revenue as % of region annual. Q70 Store net_total-band counts as % of store orders. Q71 City tier as % of city customers. Q72 Product month revenue as % of product annual. Q73 Region x status: show count, row %, and column % together. Q74 Category x quarter revenue with % of grand total per cell. Q75 Build a status mix report: per region, each status count and % of region. UNPIVOT & TIDY Q76 Unpivot revenue_summary metrics (total_revenue, total_orders, avg_order_value) to rows. Q77 Unpivot pay_slip components into (component, amount) per slip. Q78 Unpivot a region's Q1..Q4 revenue (from a pivot) back to long. Q79 Unpivot email_clicks (sent/opened/clicked) to (stage, count) per campaign. Q80 Unpivot order totals (gross/discount/net) to (kind, amount). Q81 Unpivot product price & cost_price to (kind, amount). Q82 Unpivot tax_brackets numeric columns to long. Q83 Unpivot using unnest over ARRAY[...] of labels and values. Q84 Unpivot a wide monthly KPI mock (revenue_summary by date) to (date, metric, value). Q85 Unpivot a customer's contact fields to (channel, value). Q86 Unpivot shipment dates (shipped/delivered) to events with a type label. Q87 Unpivot a store's open/close-era flags to rows. Q88 Round-trip: pivot regionxstatus then unpivot; verify counts match. Q89 Tidy a wide funnel (page/cart/checkout counts) into long stages. Q90 Unpivot then aggregate (sum the long form) to validate the pivot. Q91 Unpivot ads metrics into (metric, value) for charting. Q92 Unpivot a 12-month wide row into a tidy month series. Q93 Unpivot using LATERAL (VALUES ...) instead of UNION ALL. Q94 Unpivot product attributes into an EAV (entity-attribute-value) shape. Q95 Build a tidy (region, metric, value) table from several aggregates. Q96 Unpivot then pivot on a different axis (reshape). Q97 Compare UNION ALL unpivot vs unnest unpivot readability. Q98 Unpivot loyalty tier thresholds (min/max points) to long. Q99 Note crosstab() (tablefunc, practice) for dynamic unknown-column pivots. Q100 Deliver a tidy long-format metrics table ready for a BI tool. Interview grade, edge cases
CONCEPTUAL Q1 Build a pivot with row totals, column totals, and a grand total - approaches. Q2 GROUPING SETS vs UNION ALL for subtotal rows - tradeoffs. Q3 ROLLUP for hierarchical subtotals (region -> store). Q4 CUBE for all-combination subtotals - when it's appropriate. Q5 GROUPING() to label subtotal vs detail rows. Q6 Percent-of-row vs percent-of-column vs percent-of-grand-total. Q7 Derived ratios inside a pivot (return rate, conversion) - placement. Q8 Why FILTER keeps multi-metric pivots readable vs nested CASE. Q9 When dynamic pivot is unavoidable (unknown categories) -> crosstab/app. Q10 jsonb_object_agg for a dynamic key->value "pivot" (concept; JSON is Topic 24). Q11 Unpivot a wide table robustly (UNION ALL vs LATERAL VALUES). Q12 Avoiding double counting when pivoting over a fan-out join. Q13 Pivot stability when categories may be missing in some periods. Q14 Combining a pivot with a window % (Topic 17) for share columns. Q15 ROLLUP ordering and NULL placement of subtotal rows. Q16 Performance: pivot over a pre-aggregated CTE vs raw facts. Q17 When to pivot in SQL vs ship long format to the BI layer. Q18 Multi-grain pivot (counts and revenue) without two passes. Q19 Pivot booleans (bool_or) into capability flags. Q20 Reshape: unpivot then re-pivot on a new axis. Q21 Handling division-by-zero in ratio pivots (NULLIF). Q22 Grand-total reconciliation (row totals sum to grand total). Q23 Why GROUPING SETS can replace several UNION ALL queries. Q24 Designing a pivot that a finance team can paste into a sheet. Q25 A correctness checklist for pivot+subtotal reports. PIVOT REPORTS WITH TOTALS Q26 SCENARIO: CFO wants region x payment_mode revenue with row totals, column totals, grand total. Q27 Store x quarter revenue with a yearly total column. Q28 Category x month units with an annual total column and monthly total row. Q29 Region x status order counts with grand total (GROUPING SETS). Q30 Brand x price-band counts with brand totals. Q31 Agent x priority ticket counts with agent totals and grand total. Q32 Region x tier revenue with ROLLUP subtotals. Q33 Product x rating review counts with product total. Q34 Department x role headcount with department + company totals. Q35 Courier x month avg-delivery matrix with overall column. Q36 Region -> store revenue ROLLUP (hierarchical subtotals). Q37 Category -> brand revenue ROLLUP. Q38 Month x status revenue with monthly and status totals (CUBE). Q39 Platform x quarter spend with platform totals. Q40 Store x weekday revenue with weekend vs weekday subtotals. Q41 Warehouse x category stock with warehouse totals. Q42 Cohort-year x following-year orders with cohort totals. Q43 City x tier customers with city totals (via addresses). Q44 Region x season revenue with grand total and GROUPING() labels. Q45 Brand x customer-tier revenue with totals. Q46 Status x month order counts transposed with totals. Q47 Product x quarter revenue with product annual total. Q48 Region x payment_mode counts AND revenue interleaved with totals. Q49 Reconcile: verify row totals sum to the grand total. Q50 Deliver a finance-ready region x month revenue sheet with all margins. RATIOS & GROUPING SETS Q51 Region x status counts with each as % of region (row %). Q52 Region x status counts with each as % of status (column %). Q53 Category x month units with % of grand total per cell. Q54 Return rate matrix: returned units / delivered units per category x month. Q55 Conversion-ish matrix: orders / customers per region x tier. Q56 Store x quarter revenue indexed to Q1 = 100 (no LAG; ratio to FILTER Q1). Q57 Brand price-band counts as % of brand (row %) with brand totals. Q58 Agent priority counts as % of agent tickets. Q59 Region tier revenue with % of region and % of company. Q60 ROLLUP region->store revenue with subtotal % of region. Q61 GROUPING SETS to produce detail + region subtotal + grand total in one query. Q62 CUBE over (region, status) with all margin combinations. Q63 Product rating mix as % per product with avg rating column. Q64 Courier on-time % per month per courier (FILTER ratio matrix). Q65 Category returned/delivered with return-rate column (NULLIF guard). Q66 Month status mix as % of month AND running cumulative (with window). Q67 Region x tier with both count and revenue and revenue-per-customer. Q68 Platform quarter spend as % of platform and % of total. Q69 Store weekday revenue share (% of store week). Q70 GROUPING() to tag which rows are subtotals in a ROLLUP. Q71 Department role headcount % with company total row. Q72 Cohort retention matrix as % of cohort size (GROUPING SETS friendly). Q73 Warehouse category stock % of warehouse and of company. Q74 Region x season revenue with % of region annual. Q75 Build a mix-and-margin report: counts, row %, subtotal, grand total. UNPIVOT & RESHAPE Q76 SCENARIO: A wide quarterly KPI export must become tidy (entity, metric, period, value). Q77 Unpivot pay_slip components into long (slip, component, amount) and validate the sum = gross. Q78 Unpivot revenue_summary into (date, metric, value). Q79 Unpivot email_clicks into a funnel (campaign, stage, count) and compute drop-off. Q80 Unpivot order totals (gross/discount/net) and verify gross-discount=net. Q81 Reshape: pivot regionxstatus, then unpivot back, prove round-trip equality. Q82 Unpivot a 12-month wide row into a tidy month series via LATERAL VALUES. Q83 Unpivot product price/cost/margin into (kind, amount). Q84 Unpivot tax_brackets to long and chart the rate curve. Q85 Unpivot ads metrics into (metric, value) per campaign. Q86 Build an EAV table from several customer attributes. Q87 Unpivot shipment lifecycle dates into events with type labels. Q88 Unpivot a pivoted matrix produced earlier (columns -> rows). Q89 Tidy a funnel matrix into long stages with conversion %. Q90 Unpivot loyalty tier thresholds (min/max) to long. Q91 Reshape monthly wide -> long -> re-pivot by quarter. Q92 Unpivot using unnest over two parallel arrays (labels, values). Q93 Unpivot then GROUP BY metric to get cross-entity totals. Q94 Unpivot store KPIs (revenue, orders, aov) to long for comparison. Q95 Validate an unpivot: long-form sum equals wide-form total. Q96 Reshape a wide cohort grid into tidy (cohort, month_since, retained). Q97 Unpivot a regionxquarter pivot to (region, quarter, revenue). Q98 Produce a tidy metrics table for a dashboard from 6 aggregate columns. Q99 Note crosstab()/tablefunc (practice) for the dynamic-column case. Q100 Deliver both a pivoted finance sheet AND its tidy long-format source. Production scenarios, optimisation
CONCEPTUAL Q1 Architect a multi-metric pivot (count, revenue, AOV) with full margins in one query. Q2 GROUPING SETS vs ROLLUP vs CUBE - exact semantics and output shapes. Q3 GROUPING()/GROUPING_ID() to label and order subtotal rows. Q4 Dynamic pivot options: crosstab (tablefunc), jsonb_object_agg, app-side. Q5 Why static SQL can't return unknown-at-plan-time columns. Q6 jsonb_object_agg(key, value) as a dynamic key->value result (Topic 24 detail). Q7 Avoiding fan-out double counts when pivoting over joins. Q8 Combining pivot cells with window shares (Topic 17) safely. Q9 Reshape pipeline design: long <-> wide and when each is canonical. Q10 Performance: pre-aggregate to grain before pivoting big facts. Q11 NULL vs 0 semantics in pivots and their effect on AVG. Q12 Subtotal reconciliation guarantees (rows sum to grand total). Q13 Pivoting time buckets (hour/day/week/month) consistently. Q14 When the BI tool should pivot vs SQL (cardinality, freshness). Q15 Multi-axis reporting (region x status x month) - flatten strategy. Q16 EAV <-> wide conversions and their tradeoffs. Q17 Ratio matrices (return rate, conversion) with safe division. Q18 CUBE explosion risk on high-cardinality dimensions. Q19 Materializing a pivot into an MV (Topic 25) for dashboards. Q20 Stable column sets across periods (carry zero categories). Q21 Index-to-base (=100) matrices without LAG (ratio to a FILTERed base). Q22 Pivot + percentile (Topic 22) combos for KPI strips. Q23 Generating the dynamic crosstab column list from a query (two-step). Q24 Validating a reshape pipeline (round-trip equality + totals). Q25 A staff-level reporting checklist (grain, margins, ratios, freshness). MULTI-METRIC MATRICES Q26 SCENARIO: Build a region x month matrix with revenue, orders, AOV, and full margins. Q27 Store x quarter: revenue + units + return-rate cells. Q28 Category x month: revenue, units, and % of grand total per cell. Q29 Region x status: count, revenue, and revenue-per-order interleaved. Q30 Brand x tier: revenue, customers, revenue-per-customer. Q31 Agent x priority: ticket count, avg resolution hrs, SLA-breach %. Q32 Product x month: units, revenue, and margin. Q33 Courier x month: shipments, on-time %, avg delivery days. Q34 Department x role: headcount, avg salary, payroll share. Q35 Region x season: revenue, orders, and YoY-base ratio. Q36 Platform x quarter: spend, share %, and cumulative. Q37 Warehouse x category: stock, turns, and % of warehouse. Q38 Cohort x month-since: customers, revenue, retention %. Q39 City x tier: customers, spend, spend-per-customer. Q40 Month x status: revenue with ROLLUP subtotals and labels. Q41 Region x payment_mode: revenue with CUBE all-margins. Q42 Category -> brand revenue ROLLUP with subtotal %. Q43 Store x weekday: revenue, orders, and weekend subtotal. Q44 Region x tier: revenue, % of region, % of company (3 ratios). Q45 Product rating mix with avg rating and negative-review %. Q46 Region x month with revenue, MoM-base (FILTER prev month), and growth %. Q47 Brand x price-band counts, revenue, and contribution %. Q48 Multi-metric finance sheet: region x quarter revenue, cost, margin %. Q49 Reconcile every margin in a multi-metric matrix. Q50 Deliver an exec multi-metric matrix (region x month, 4 metrics, full margins). DYNAMIC-PIVOT STRATEGY Q51 SCENARIO: Categories change over time - design a dynamic payment_mode pivot strategy. Q52 Two-step dynamic pivot: query the distinct columns, then build the SQL (describe). Q53 (practice) crosstab() from tablefunc for region x dynamic-status. Q54 jsonb_object_agg(status, cnt) per region as a dynamic "pivot" (Topic 24 detail). Q55 Compare static FILTER pivot vs jsonb dynamic result. Q56 Generate the column list for a month pivot dynamically (distinct months). Q57 Dynamic brand pivot - why app-side or crosstab is required. Q58 (practice) crosstab with a category source query + values query. Q59 jsonb_object_agg for product -> units map per brand. Q60 Handle new categories gracefully (json grows; static pivot doesn't). Q61 Build a key->value JSON per customer for a flexible report (Topic 24 preview). Q62 Decide crosstab vs jsonb vs app pivot for a dashboard (tradeoffs). Q63 Dynamic pivot of order_status counts per month as JSON. Q64 Dynamic region pivot of revenue as JSON keyed by region. Q65 Convert a jsonb "pivot" back to columns when the keys are known. Q66 (practice) crosstab for agent x priority counts. Q67 Dynamic tier pivot per region as JSON with totals. Q68 Strategy memo: when to push dynamic pivot to the BI tool. Q69 jsonb_object_agg with COALESCE for missing categories. Q70 Two-query approach: distinct columns + a generated pivot statement (outline). Q71 Dynamic month-bucket pivot for a rolling 12-month window. Q72 Compare maintainability: static FILTER vs dynamic crosstab. Q73 jsonb per store of status->count for a flexible front end. Q74 Validate a dynamic pivot's totals against a static aggregate. Q75 Recommend a dynamic-pivot approach for the analytics platform. RESHAPE PIPELINES Q76 SCENARIO: Ingest a wide quarterly KPI export -> tidy long -> re-pivot by metric. Q77 Unpivot pay_slips to components, validate sum=gross, re-pivot by month. Q78 Unpivot revenue_summary to (date, metric, value), then pivot metricxmonth. Q79 Reshape email_clicks into a funnel long form with stage drop-off. Q80 Round-trip a regionxstatus pivot (wide->long->wide) and prove equality. Q81 Build an EAV from customer attributes, then pivot back selected keys. Q82 Unpivot order totals, aggregate by kind, re-pivot by month. Q83 Reshape a 12-month wide row to long via LATERAL VALUES then bucket by quarter. Q84 Unpivot ads metrics, join to campaigns, re-pivot by platform. Q85 Tidy a cohort grid (wide month-since columns) into long and validate. Q86 Reshape store KPIs (revenue/orders/aov) long, rank within metric (Topic 16). Q87 Unpivot tax_brackets, chart the curve, re-pivot by rate band. Q88 Convert a jsonb pivot to long via jsonb_each (Topic 24 preview). Q89 Pipeline: facts -> pre-aggregate -> pivot -> percent-of-row -> export. Q90 Reshape web funnel counts into stages with conversion %. Q91 Unpivot product price/cost/margin, aggregate by kind across catalog. Q92 Build a tidy (entity, metric, period, value) table from 3 sources. Q93 Validate a reshape pipeline end-to-end (totals + round-trip). Q94 Long->wide for a finance sheet, wide->long for a data scientist - one source. Q95 Reshape regionxquarter->long->regionxyear via re-aggregation. Q96 Unpivot loyalty thresholds, compute gaps between tiers. Q97 Pipeline that emits both pivoted and tidy outputs from one CTE. Q98 Reshape a multi-metric matrix into a tidy metric column. Q99 Document the reshape pipeline for reproducibility. Q100 Deliver a full reshape pipeline: ingest wide -> tidy -> curated pivots + tidy export.