mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
17 lines
345 B
SQL
17 lines
345 B
SQL
SELECT
|
|
c_count,
|
|
count(*) AS custdist
|
|
FROM (
|
|
SELECT
|
|
c_custkey,
|
|
count(o_orderkey) AS c_count
|
|
FROM customer
|
|
LEFT OUTER JOIN orders ON (c_custkey = o_custkey)
|
|
AND (o_comment NOT LIKE '%special%requests%')
|
|
GROUP BY c_custkey
|
|
) AS c_orders
|
|
GROUP BY c_count
|
|
ORDER BY
|
|
custdist DESC,
|
|
c_count DESC;
|