mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-09 22:42:57 +00:00
28 lines
445 B
SQL
28 lines
445 B
SQL
-- $ID$
|
|
-- TPC-H/TPC-R Customer Distribution Query (Q13)
|
|
-- Functional Query Definition
|
|
-- Approved February 1998
|
|
|
|
|
|
select
|
|
c_count,
|
|
count(*) as custdist
|
|
from
|
|
(
|
|
select
|
|
c_custkey,
|
|
count(o_orderkey)
|
|
from
|
|
customer left outer join orders on
|
|
c_custkey = o_custkey
|
|
and o_comment not like '%special%accounts%'
|
|
group by
|
|
c_custkey
|
|
) as c_orders (c_custkey, c_count)
|
|
group by
|
|
c_count
|
|
order by
|
|
custdist desc,
|
|
c_count desc
|
|
;
|