Files
doris/tools/tpcds-tools/queries/sf10000/query93.sql
xzj7019 9a7d4f906b [enhance](Tools): update tpcds tools #23308
Update tpcds tools: add sf1000 & sf10000 related sql and config.
2023-08-22 17:10:50 +08:00

16 lines
771 B
SQL

select ss_customer_sk
,sum(act_sales) sumsales
from (select ss_item_sk
,ss_ticket_number
,ss_customer_sk
,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
else (ss_quantity*ss_sales_price) end act_sales
from store_sales left outer join store_returns on (sr_item_sk = ss_item_sk
and sr_ticket_number = ss_ticket_number)
,reason
where sr_reason_sk = r_reason_sk
and r_reason_desc = 'reason 66') t
group by ss_customer_sk
order by sumsales, ss_customer_sk
limit 100;