forked from agirish/tpcds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query6.sql
23 lines (23 loc) · 870 Bytes
/
query6.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- start query 6 in stream 0 using template query6.tpl
SELECT a.ca_state state,
Count(*) cnt
FROM customer_address a,
customer c,
store_sales s,
date_dim d,
item i
WHERE a.ca_address_sk = c.c_current_addr_sk
AND c.c_customer_sk = s.ss_customer_sk
AND s.ss_sold_date_sk = d.d_date_sk
AND s.ss_item_sk = i.i_item_sk
AND d.d_month_seq = (SELECT DISTINCT ( d_month_seq )
FROM date_dim
WHERE d_year = 1998
AND d_moy = 7)
AND i.i_current_price > 1.2 * (SELECT Avg(j.i_current_price)
FROM item j
WHERE j.i_category = i.i_category)
GROUP BY a.ca_state
HAVING Count(*) >= 10
ORDER BY cnt
LIMIT 100;