mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
27 lines
569 B
SQL
27 lines
569 B
SQL
SELECT
|
|
c_custkey,
|
|
c_name,
|
|
sum(l_extendedprice * (1 - l_discount)) AS revenue,
|
|
c_acctbal,
|
|
n_name,
|
|
c_address,
|
|
c_phone,
|
|
c_comment
|
|
FROM customer, orders, lineitem, nation
|
|
WHERE (c_custkey = o_custkey)
|
|
AND (l_orderkey = o_orderkey)
|
|
AND (o_orderdate >= date '1993-10-01')
|
|
AND (o_orderdate < date '1993-10-01' + INTERVAL 3 MONTH)
|
|
AND (l_returnflag = 'R')
|
|
AND (c_nationkey = n_nationkey)
|
|
GROUP BY
|
|
c_custkey,
|
|
c_name,
|
|
c_acctbal,
|
|
c_phone,
|
|
n_name,
|
|
c_address,
|
|
c_comment
|
|
ORDER BY revenue DESC
|
|
LIMIT 20;
|