Median, Percentiles and DISTINCT ON: 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 the median represent, and how does it differ from the mean (AVG)? Q2 Why is the median more robust to outliers than the average? Q3 What does PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x) compute? Q4 What is the WITHIN GROUP (ORDER BY ...) clause for? Q5 Difference between PERCENTILE_CONT (interpolates) and PERCENTILE_DISC (real value)? Q6 What do "P90" and "P95" mean as percentiles? Q7 Why is P95 a common SLA / latency metric instead of the average? Q8 What values do PERCENTILE_CONT(0.0) and PERCENTILE_CONT(1.0) return? Q9 Is PERCENTILE_CONT an aggregate like SUM/AVG? (ordered-set aggregate) Q10 Can PERCENTILE_CONT be combined with GROUP BY for a per-group median? Q11 What does DISTINCT ON (col) do in PostgreSQL? Q12 Why must DISTINCT ON normally be paired with an ORDER BY? Q13 Which row does DISTINCT ON keep per group (first by the ORDER BY)? Q14 How is DISTINCT ON different from GROUP BY? Q15 How is DISTINCT ON different from filtering ROW_NUMBER() = 1 (Topic 16)? Q16 Why is DISTINCT ON a PostgreSQL-specific shortcut? Q17 What does "latest record per group" mean for an analyst (give an example)? Q18 Why does PERCENTILE_CONT interpolate between two neighbouring values? Q19 When would you prefer PERCENTILE_DISC (must return an actual observed value)? Q20 What does the mode() WITHIN GROUP (ORDER BY x) aggregate return? Q21 How do percent_rank() / cume_dist() (Topic 16) relate to percentiles? Q22 How does NTILE(100) (Topic 16) approximate percentile buckets? Q23 Why can median delivery time tell a different story than average delivery time? Q24 Can you pass an array of fractions, e.g. PERCENTILE_CONT(ARRAY[0.5,0.9,0.95])? Q25 Name two business KPIs better expressed as a median than as a mean. MEDIAN & PERCENTILES Q26 Median net_total across all orders. Q27 Average vs median net_total side by side in one row. Q28 P90 and P95 of net_total across all orders. Q29 Median net_total per region (orders -> stores -> region). Q30 Median net_total per store. Q31 P95 net_total per region. Q32 Median order value per payment_mode. Q33 Median delivery time in days (delivered_date - order_date) for Delivered orders. Q34 P90 delivery time in days across Delivered orders. Q35 Median delivery time in days per region. Q36 Median review rating per product. Q37 Median call_duration_seconds per agent. Q38 P95 call_duration_seconds across all calls. Q39 Median refund_amount across all returns. Q40 Median net_salary from pay_slips. Q41 P90 net_salary per department. Q42 Median line quantity from order_items. Q43 Median unit price (order_items) per category. Q44 Median daily ad spend per platform. Q45 Median points_balance of loyalty members per tier. Q46 Median net_total per customer tier (Bronze..Platinum). Q47 Median ticket resolution hours (resolved_date - created_date). Q48 P95 ticket resolution hours per priority. Q49 Median order value per month for 2025. Q50 Median AND P95 net_total per region in one query (ARRAY of fractions). DISTINCT ON - latest record per group Q51 Latest order per customer: DISTINCT ON (cust_id) ORDER BY cust_id, order_date DESC. Q52 The most-recent order_status per customer. Q53 Latest review per customer. Q54 Latest review per product. Q55 Most-recent ticket per customer. Q56 Latest payment per order. Q57 Latest shipment row per order. Q58 Most-recent inventory snapshot per warehouse x product. Q59 Latest salary_history row per employee. Q60 Most-recent price a product sold at (order_items via order_date). Q61 Latest page_view per customer. Q62 First (earliest) order per customer (ORDER BY order_date ASC). Q63 Highest-value order per customer (ORDER BY net_total DESC). Q64 Cheapest order per customer. Q65 Latest call per agent. Q66 Most-recent redemption per member. Q67 Latest order per store. Q68 Latest order per region. Q69 Newest customer per region (join addresses). Q70 Latest ad spend row per platform. Q71 Most-recent expense per store. Q72 Latest work_order per production line. Q73 Top-rated review per product (ORDER BY rating DESC). Q74 Latest attendance row per employee. Q75 Most-recent transfer per account. COMBINED / MIXED Q76 Per customer: median net_total and the date of their latest order. Q77 Per region: median order value and the single latest order. Q78 Per store: median net_total and the most-recent order_status. Q79 Median delivery time in days per warehouse (orders -> stores -> warehouse). Q80 Take each customer's latest order, then report the median net_total of those. Q81 P95 net_total per region, sorted descending. Q82 Per product: median rating and the latest review's text. Q83 Per agent: median call duration and their latest call timestamp. Q84 Per customer: median resolution time and their latest ticket. Q85 Per tier: median net_total and count of customers. Q86 Median vs average net_total per region (show the gap). Q87 P90 net_total per payment_mode, only modes with > 100 orders. Q88 Latest *Delivered* order per customer (filter status, then DISTINCT ON). Q89 Median net_total computed over each customer's most-recent order only. Q90 Per category: median unit price and the latest selling price. Q91 Per tier: median points_balance and the latest join_date. Q92 P95 delivery days per region, only regions with > 500 orders. Q93 Median order value for Gold/Platinum customers, per region. Q94 Latest order per customer whose net_total is above the global median. Q95 Per store: median net_total and P95 net_total as two columns. Q96 Per month: median net_total and the latest order of that month. Q97 Customers whose latest order is Returned (DISTINCT ON + filter). Q98 Median refund_amount per region (returns -> orders -> stores -> region). Q99 Median order value per region pivoted by quarter (Topic 21 pivot + percentile). Q100 Executive KPI strip: median and P95 order value per region in one tidy result. Combined ideas, multi-step thinking
CONCEPTUAL Q1 Why does PERCENTILE_CONT interpolate while PERCENTILE_DISC snaps to a real row? Q2 Show the exact output difference of CONT vs DISC on an even-count set {10,20,30,40}. Q3 Why is median exactly PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x)? Q4 How do you compute several percentiles in one pass using an ARRAY argument? Q5 How do you unnest the array result of PERCENTILE_CONT(ARRAY[0.5,0.9,0.95])? Q6 Why can't PERCENTILE_CONT appear directly in a WHERE clause? Q7 How does DISTINCT ON break ties - what decides which row wins? Q8 Why add a deterministic tiebreaker (e.g. order_id) to DISTINCT ON's ORDER BY? Q9 DISTINCT ON vs ROW_NUMBER() OVER(...) - when is each cleaner? Q10 Why must the DISTINCT ON column(s) be the leftmost ORDER BY keys? Q11 Compare the cost of DISTINCT ON vs a correlated subquery for latest-per-group. Q12 Can PERCENTILE_CONT be used as a window function with OVER (and what changes)? Q13 What does mode() WITHIN GROUP return when two values tie for most-frequent? Q14 How do you combine FILTER (WHERE ...) (Topic 21) with a percentile aggregate? Q15 Why does a per-group median need GROUP BY but DISTINCT ON does not? Q16 How does NTILE(4) (Topic 16) give quartile buckets vs PERCENTILE_CONT cut points? Q17 Define percent_rank() vs cume_dist() precisely. Q18 Why can P50 from PERCENTILE_CONT differ from the NTILE(2) boundary value? Q19 How do you compute the interquartile range (P75 - P25)? Q20 For outlier fences via 1.5xIQR, which percentiles do you need? Q21 Why does DISTINCT ON keep the entire row, not just the key column? Q22 How would you emulate DISTINCT ON in standard SQL (ROW_NUMBER filter)? Q23 How do you take the median of a *computed* expression (e.g. delivery days)? Q24 Do ordered-set aggregates include or ignore NULLs in the ordering input? Q25 When is a single median misleading (e.g. a bimodal distribution)? PERCENTILES WITH JOINS & GROUPS Q26 Median and P95 net_total per region (full join chain). Q27 Median delivery days per warehouse (orders -> stores -> warehouse). Q28 Median, P90 and P95 of net_total per store in one query (ARRAY). Q29 P25, P50, P75 of net_total per region (quartiles via ARRAY). Q30 Interquartile range (P75 - P25) of net_total per region. Q31 Median unit price per category (order_items -> products -> brand -> category). Q32 Median basket size (items per order) per store. Q33 Median order value per customer tier, only tiers with > 1000 customers. Q34 Median review rating per brand. Q35 Median call duration per agent, only agents with > 50 calls. Q36 P95 ticket resolution hours per priority. Q37 Median net_salary per department, with headcount alongside. Q38 Median gap (days) between consecutive orders per customer (LAG, Topic 18, then median). Q39 Median monthly revenue per region (group by month, then median across months). Q40 Median ad spend per platform per quarter. Q41 P90 delivery days per region, excluding Cancelled/Failed orders. Q42 Median points_balance per tier with member counts. Q43 Median refund_amount per category (returns -> products -> category). Q44 Median order value per weekday (day-of-week). Q45 Median order value for new vs returning customers (first-order flag via window). Q46 Median gross margin per category (item revenue - cost_price). Q47 Median time-to-first-order in days per registration-year cohort. Q48 Median net_total per store, ranked, top 10 (Topic 16 RANK). Q49 Median vs mean net_total per region with the spread and % difference. Q50 P95 net_total per payment_mode with order counts (FILTER mix). DISTINCT ON across tables Q51 Latest order (full row) per customer, with the store name. Q52 Most-recent review per product, with the reviewer's name. Q53 Latest ticket per customer, with priority and subject. Q54 Most-recent payment per order, with the payment_mode name. Q55 Latest inventory snapshot per warehouse x product, with quantity. Q56 Latest salary per employee, with department. Q57 Most-recent price each product sold at (latest order_items by order_date). Q58 Latest order per customer, plus days since that order. Q59 First and latest order per customer (two DISTINCT ON queries, joined). Q60 Most-recent *Delivered* order per customer. Q61 Latest call per agent, with duration. Q62 Newest customer per city (addresses). Q63 Latest redemption per member, with points. Q64 Most-recent expense per store, with amount. Q65 Latest page_view per customer, with page_url. Q66 Highest-rated review per product (tie-break by latest review_date). Q67 Latest order per store, with net_total and status. Q68 Most-recent work_order per production line. Q69 Latest attendance per employee, with status. Q70 Latest order per region (one row per region). Q71 Most-recent ad spend per platform, with amount. Q72 Latest shipment per order, with status and date. Q73 Each customer's single largest order (DISTINCT ON by net_total DESC). Q74 Latest transfer per account, with amount. Q75 Most-recent ticket per agent. PERCENTILE + PIVOT / WINDOW INTEGRATION Q76 Median net_total per region x quarter pivot (Topic 21). Q77 P95 net_total per region x month matrix. Q78 Median delivery days per region x quarter. Q79 Each customer's latest order plus that order's percent_rank of net_total (Topic 16). Q80 Flag orders above their region's P90 (join the regional P90 back to each order). Q81 Median order value per region with a rolling per-quarter view (window framing). Q82 Customers whose latest order exceeds their own median order value. Q83 Per store: median net_total, then rank stores by it (Topic 16). Q84 Region median vs each store's median (gap to the regional benchmark). Q85 NTILE(10) deciles of net_total vs PERCENTILE_CONT cut points, side by side. Q86 Per category: median price and the latest selling price (DISTINCT ON + percentile). Q87 Per agent: median resolution time and their latest ticket status. Q88 Executive KPI strip: count, median, P95 order value per region. Q89 Median basket size per store pivoted by quarter. Q90 Customers above the global P95 net_total whose latest order is Returned. Q91 Per region: median order value and the % of orders above it. Q92 IQR-based outlier orders per region (net_total beyond P75 + 1.5.IQR). Q93 Median monthly revenue per region with the latest month flagged. Q94 Per tier: median order value and the single most-recent order. Q95 P90 / P95 / P99 net_total per region (ARRAY) as three columns. Q96 Median delivery days per warehouse, plus the latest snapshot quantity. Q97 Rank regions by median order value, showing P95 alongside. Q98 Per payment_mode: median order value pivoted by region. Q99 Median net_total per customer cohort (registration year) x order year. Q100 Full exec dashboard: per region - median, P90, P95 order value + latest order date. Interview grade, edge cases
CONCEPTUAL Q1 Implement median three ways (PERCENTILE_CONT, NTILE, manual row-offset) - tradeoffs. Q2 Why can't PERCENTILE_CONT use an index, and what does that imply at scale? Q3 Approximate percentiles for huge tables - strategies (sampling, t-digest concept). Q4 Median as a window function vs as a grouped aggregate - output differences. Q5 DISTINCT ON vs ROW_NUMBER vs correlated subquery vs LATERAL - full comparison. Q6 What plan would DISTINCT ON over 150k orders produce (sort vs incremental)? (Topic 19) Q7 Which index makes latest-per-group fast: composite (group_key, ts DESC)? (Topic 20) Q8 Why does a covering index enable an index-only scan for DISTINCT ON? (Topic 20) Q9 Computing P95 latency from event timestamps - common pitfalls. Q10 How are NULLs handled in the ordering column of PERCENTILE_CONT? Q11 Weighted median - why SQL lacks it natively and how to approximate it. Q12 Median-of-group-medians vs the true global median - why they differ. Q13 Explain the interpolation math of PERCENTILE_CONT (the fractional-row formula). Q14 Trimmed mean (drop top/bottom 5%) implemented with percentiles. Q15 Outlier detection: IQR fences vs z-score vs percentile clipping. Q16 Why P50 != AVG, and what the gap reveals about skew. Q17 DISTINCT ON pitfalls when the ORDER BY tiebreaker is non-unique. Q18 Making "latest" reproducible when timestamps collide - tiebreak strategy. Q19 Streaming / online percentile estimation - the core idea. Q20 When to precompute group medians into a summary table / MV (Topic 25 preview). Q21 Cost of many group medians - sort vs hash, and work_mem effects (Topic 19). Q22 Median over a sliding window - the frame problem (Days 17-18). Q23 Why GROUPING SETS combined with PERCENTILE_CONT can get expensive. Q24 When PERCENTILE_DISC is required for an SLA (must be a real observed value). Q25 Designing a percentile-based alerting metric (what to compute, how often). DISTRIBUTION & PERCENTILE REPORTS Q26 Five-number summary (min, P25, P50, P75, max) of net_total per region. Q27 IQR and outlier fences per region; count the outliers beyond each fence. Q28 Trimmed mean of net_total per region (drop below P5 and above P95). Q29 P50/P90/P95/P99 of net_total per region (ARRAY) as columns, ranked by P95. Q30 Delivery-time distribution per warehouse: median, P90, P95, max. Q31 Median and P95 ticket resolution hours per priority; flag SLA breaches. Q32 Per agent: median and P95 call duration; rank worst P95 (Topic 16). Q33 Income distribution: P25/P50/P75 net_salary per department. Q34 Per category: median margin % and P10 (worst-margin tail). Q35 Basket-size distribution per store (median, P90). Q36 Median gap-between-orders per customer, then the distribution of those medians. Q37 Order-value percentiles per tier with skew (mean - median). Q38 Revenue concentration per region: the P95 / P50 ratio. Q39 Median order value per region x quarter with QoQ change (LAG, Topic 18). Q40 Per store: median net_total and its percent_rank among all stores (Topic 16). Q41 Delivery SLA: % of orders delivered within the regional P90 target, per region. Q42 Median time-to-resolution by ticket priority. Q43 P95 session/dwell metric per device type (web_events.page_views). Q44 Per platform: median and P95 daily ad spend. Q45 Median refund per category alongside the refund rate. Q46 Cohort median order value (registration year) x subsequent order year matrix. Q47 Per region: median order value among repeat customers only. Q48 Weekly median revenue per region with a 4-week moving median (window). Q49 Bucket each customer by lifetime value with NTILE(4); show the PERCENTILE cut points. Q50 Outlier orders beyond P99 net_total per region, with customer and store context. LATEST-PER-GROUP AT SCALE Q51 Latest order per customer via DISTINCT ON; rewrite with ROW_NUMBER; confirm identical rows. Q52 Latest Delivered order per customer with days-since and store. Q53 Most-recent price per product (latest order_items) plus current cost margin. Q54 Latest snapshot per warehouse x product + reorder flag (qty < reorder_level). Q55 Latest salary per employee + % change vs the previous salary (LAG, Topic 18). Q56 Each customer's latest order AND latest ticket in one report (two DISTINCT ON joined). Q57 Latest review per product with a running count of reviews (window). Q58 Most-recent status per shipment with age in days. Q59 Latest order per store, ranked by recency gap (stalest stores first). Q60 Customers whose latest order is Returned/Cancelled - churn-risk list. Q61 Latest order per customer, then rank customers by recency across the base. Q62 Most-recent payment per order, flagging where the latest payment Failed. Q63 Latest attendance per employee, flagging absentees. Q64 Per region: the single most-recent order with full context. Q65 Latest redemption per member + points remaining. Q66 First vs latest order per customer (two DISTINCT ON) + lifetime span in days. Q67 Latest call per agent + that call's percentile duration (Topic 16). Q68 Newest customer per city with tier. Q69 Most-recent expense per store + YoY change. Q70 Latest work_order per line + cycle time. Q71 Each customer's single highest-value order (DISTINCT ON by value) + its percentile. Q72 Latest order per payment_mode. Q73 Most-recent inventory snapshot per warehouse with total stock value (qty x cost_price). Q74 Latest ticket per agent with resolution status. Q75 Build a "current state" set: exactly one latest order row per customer. PRODUCTION KPI / EXEC DASHBOARDS Q76 Executive KPI strip per region: orders, median AOV, P95 AOV, latest order date. Q77 Region scorecard: median AOV, P95 AOV, median delivery days, SLA% - one row per region. Q78 Store leaderboard: median net_total, P95, rank, decile (Topic 16). Q79 Tier dashboard: per tier median AOV, P90, member count, latest signup. Q80 Delivery SLA dashboard per warehouse: median, P95, breach count and %. Q81 Support SLA: per priority median & P95 resolution, breach %, latest open ticket. Q82 Agent performance: median & P95 call duration, latest call, rank. Q83 Category margin board: median margin %, P10 tail, latest selling price. Q84 Cohort retention value: median AOV by registration year x order year (pivot). Q85 Outlier monitor: per region orders beyond P99, with customer and recency. Q86 Churn-risk board: customers whose latest order is Returned + lifetime median. Q87 Revenue health: per region median monthly revenue + QoQ trend (window). Q88 Pricing drift: per product latest selling price vs median historical price. Q89 Inventory freshness: per warehouse latest snapshot age + stockout flags. Q90 Delivery funnel: median time order->ship and ship->deliver per region. Q91 KPI matrix: region x quarter median AOV pivot with row and column medians. Q92 Top vs bottom decile customers by lifetime value, with the cut points. Q93 P95 latency board from web_events per device + peak hour (Topic 18 hour bucket). Q94 Salary equity: per department median, P25, P75, IQR, headcount. Q95 "Most-recent everything": per customer latest order / review / ticket in one wide row. Q96 Region benchmark gap: each store's median vs its region's median. Q97 Trimmed-mean revenue per region vs raw mean vs median (three columns). Q98 Quarterly exec strip: median + P95 AOV per region per quarter, latest quarter flagged. Q99 SLA alert query: regions whose P95 delivery exceeds target this month. Q100 One-screen CXO dashboard: per region median/P90/P95 AOV, SLA%, latest order, rank. Production scenarios, optimisation
CONCEPTUAL Q1 Design an approximate-percentile service for billions of rows (t-digest / sketch) - concept. Q2 Exact vs approximate percentiles: error budgets and when each is acceptable. Q3 Incremental / streaming median maintenance as new orders arrive. Q4 Reservoir sampling to bound the cost of a percentile query. Q5 Merging percentile sketches across shards / partitions - why naive averaging fails. Q6 Histogram-bucket percentiles vs PERCENTILE_CONT - accuracy / performance tradeoff. Q7 Latest-per-group at 100M rows: index design, partitioning, MV refresh (Days 20/25). Q8 Keeping a "current state" table fresh: trigger vs incremental MV vs batch reload. Q9 DISTINCT ON vs LATERAL Top-1 vs window - plan and cost at scale (Topic 19). Q10 Weighted percentiles (weight by order value) - algorithm sketch in SQL. Q11 P99 / P99.9 stability - minimum sample size required per group. Q12 Median in a sliding time window for a real-time dashboard - design. Q13 Guarding percentile metrics against data skew and NULL floods. Q14 Choosing PERCENTILE_DISC for a contractual SLA threshold - why exact-observed matters. Q15 Backfilling historical percentiles into a summary fact table - idempotency. Q16 Multi-tenant percentile isolation (per-tenant medians with no cross-leak). Q17 Cost model: sort-based ordered-set aggregate vs hash; tuning work_mem (Topic 19). Q18 Alerting on percentile drift (week-over-week P95 shift) - metric + threshold design. Q19 Trimmed / winsorized aggregates as outlier-robust KPIs - when to prefer each. Q20 Reconciling median-of-group-medians with the true global median for rollups. Q21 Designing a percentile API contract (P50/P90/P95/P99) for the BI layer. Q22 Idempotent "latest snapshot" pipeline tolerant of late-arriving data. Q23 SCD type-2 read: latest-attribute-per-entity (e.g. tier over time) via DISTINCT ON. Q24 Percentile-based guardrails for dynamic pricing. Q25 When to push percentile / latest computation into an MV vs compute live (Topic 25). MULTI-METRIC DISTRIBUTION ENGINES Q26 One-query distribution engine: per region count, mean, P25/50/75/90/95/99, IQR, skew. Q27 Robust region scorecard: trimmed mean, median, spread, outlier count. Q28 Delivery-performance matrix per warehouse: median/P90/P95/max + SLA breach % + trend (window). Q29 Customer-LTV distribution per tier: full P-spectrum + concentration (P95/P50 ratio). Q30 Margin distribution per category: median, P10 tail, % of products below target margin. Q31 Support SLA engine: per priority median/P95/P99 resolution, breach %, oldest-open (DISTINCT ON). Q32 Agent ops board: median/P95 call duration, latest call, recency rank, peak hour (Topic 18). Q33 Pricing corridor per product: P25-P75 selling-price band + latest-price drift. Q34 Revenue concentration: per region top-decile share vs median (NTILE + percentile). Q35 Basket analytics: per store median basket size, P90, mix vs region benchmark. Q36 Cohort value spectrum: registration-year x order-year median AOV matrix (pivot) + diagonal trend. Q37 Outlier engine: per region IQR fences + P99, with flagged orders and full context. Q38 Seasonality view: per region median AOV per quarter with QoQ and YoY change (window). Q39 Equity audit: per department salary P25/50/75, IQR, gap-to-org-median. Q40 Web latency SLO: per device P50/P95/P99 session metric + peak-hour bucket. Q41 Inventory health: per warehouse latest snapshot + stockout %, median days-of-cover. Q42 Refund risk: per category median refund, refund rate, P95 refund, latest spike. Q43 Delivery funnel timings: median + P95 of order->ship and ship->deliver per region. Q44 Repeat-purchase cadence: per customer median inter-order gap; distribution of cadences. Q45 Dynamic SLA targets: set each region's target = its own prior-quarter P90; measure attainment. Q46 Price-band elasticity proxy: median units at each price-percentile band per category. Q47 Multi-stage pipeline: per-customer median -> per-region median-of-medians vs true global. Q48 Anomaly sweep: regions whose P95 AOV shifted more than X% week-over-week. Q49 Winsorized revenue: clamp net_total to [P1,P99] per region; compare to raw totals. Q50 Full distribution pivot: region x quarter median AOV with row/col medians + grand median. LATEST-STATE / SCD PIPELINES Q51 Build a "customer current state" row: latest order, review, ticket, payment in one wide row. Q52 SCD-type-2 read: latest tier per customer over time (DISTINCT ON tier_updated_at). Q53 Idempotent latest-snapshot: per warehouse x product newest row + reorder flag + value. Q54 Pricing book: most-recent selling price per product + corridor + days-since-change. Q55 Churn engine: customers whose latest order is Returned/Cancelled + lifetime median + recency decile. Q56 Employee current comp: latest salary per employee + % change + percentile within department. Q57 Latest-vs-first delta per customer: span days, value growth, order-frequency change. Q58 Per-region freshest order with full enrichment (store, customer, items, payment). Q59 "Most-recent activity" unifier across orders/reviews/tickets/calls per customer (latest of any). Q60 Stalest entities: stores / agents ranked by recency of their last activity. Q61 Latest payment status per order -> reconcile a Failed-latest against finance.payments. Q62 Current inventory valuation: latest snapshot per SKU x cost_price -> total value. Q63 Latest attendance per employee -> absentee list + tenure context. Q64 Versioned price changes: per product the sequence of distinct prices, latest highlighted (window + DISTINCT ON). Q65 Per customer: latest order's percentile rank vs their own order history (Topic 16). Q66 Build a "delta since last snapshot" per warehouse x product. Q67 Latest campaign spend per platform + pacing vs budget. Q68 Most-recent ticket per agent + open-aging + SLA flag. Q69 Customer "last seen": unified max timestamp across web_events and orders. Q70 Latest redemption + remaining points + tier-benefit eligibility. Q71 SCD read: latest address per customer (if multiple) for the current city. Q72 Per store: latest order + rolling 30-day median context (window + DISTINCT ON). Q73 Freshness SLA: entities whose latest activity is older than a threshold. Q74 Latest work_order per line + cycle-time percentile. Q75 One-pass "current state of the business": latest KPI snapshot per region. PRODUCTION ANALYTICS SYSTEMS Q76 CXO single-screen: per region median/P90/P95 AOV, SLA%, latest order, churn-risk count, rank. Q77 Real-time-ish ops monitor: per warehouse P95 delivery, breach %, freshest snapshot age. Q78 Pricing governance: per product latest price vs P25-P75 corridor; flag drift; latest change date. Q79 Customer health score: blend latest-recency decile + lifetime-median percentile + return flag. Q80 SLA alerting pipeline: regions/priorities breaching P95 targets this period vs last (window). Q81 Cohort LTV dashboard: reg-year x order-year median AOV pivot + retention curve + latest cohort. Q82 Outlier & fraud sweep: per region P99 fences + customers with an anomalous latest order. Q83 Inventory replenishment board: latest snapshot per SKU, median days-of-cover, stockout risk. Q84 Workforce equity report: per department salary percentile spread + gap-to-median + latest hire. Q85 Support command center: per priority median/P95/P99 resolution, breach %, oldest-open ticket. Q86 Revenue distribution monitor: per region winsorized vs raw vs median, week-over-week drift. Q87 Web performance SLO board: per device P50/P95/P99 + peak hour + worst recent session. Q88 Margin protection: per category median margin, P10 tail, products below floor, latest price. Q89 Delivery-funnel SLA: per region median + P95 of each stage, end-to-end P95, breach %. Q90 Pricing-elasticity matrix: price-band percentile x median units per category. Q91 "Latest everything" mart: one wide current-state row per customer for the BI layer. Q92 Dynamic-target SLA engine: target = prior-quarter P90 per region; this-quarter attainment. Q93 Anomaly digest: top regions by week-over-week P95 AOV shift, with drill-down context. Q94 Executive percentile API result: per region ARRAY[P50,P90,P95,P99] for AOV, delivery, resolution. Q95 Concentration & equity: per region revenue P95/P50 ratio + top-decile share + median. Q96 Full reshape pipeline: unpivot KPIs -> percentile per metric -> re-pivot region x metric (Topic 21). Q97 Freshness + distribution combined: per region latest order + median/P95 in one statement. Q98 Multi-grain rollup: store -> region -> all medians via GROUPING SETS + reconciliation note. Q99 Production "morning report": per region orders, median/P95 AOV, SLA%, churn-risk, freshest order, rank - one query. Q100 Capstone: the per-region executive distribution dashboard (median, P90, P95, P99, IQR, SLA%, latest order, decile rank) as one production query.