mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 14:28:22 +00:00
23 lines
384 B
SQL
23 lines
384 B
SQL
-- using default substitutions
|
|
|
|
|
|
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%requests%'
|
|
group by
|
|
c_custkey
|
|
) as c_orders (c_custkey, c_count)
|
|
group by
|
|
c_count
|
|
order by
|
|
custdist desc,
|
|
c_count desc;
|