ntile
ntile(n) cuts the ordered rows into n nearly equal buckets.
task
Split customers who ordered into 4 spend quartiles (spend = sum of unit_cents * qty, ties by customer_id, lowest spend is quartile 1). Return the quartile of customer 10.
Run a query to see rows here.
Run EXPLAIN on the statement under the cursor: Plan tab, button Explain.
No tables yet.
ntile(n) cuts the ordered rows into n nearly equal buckets.
Split customers who ordered into 4 spend quartiles (spend = sum of unit_cents * qty, ties by customer_id, lowest spend is quartile 1). Return the quartile of customer 10.