blob: 4dadc188eb5f6d43a7358707a3e180d68e7d95be (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
--!syntax_pg
--TPC-DS Q93
-- start query 1 in stream 0 using template ../query_templates/query93.tpl
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)::numeric*ss_sales_price
else (ss_quantity::numeric*ss_sales_price) end act_sales
from plato.store_sales left outer join plato.store_returns on (sr_item_sk = ss_item_sk
and sr_ticket_number = ss_ticket_number)
,plato.reason
where sr_reason_sk = r_reason_sk
and r_reason_desc = 'Did not like the warranty') t
group by ss_customer_sk
order by sumsales, ss_customer_sk
limit 100;
-- end query 1 in stream 0 using template ../query_templates/query93.tpl
|