-
Notifications
You must be signed in to change notification settings - Fork 10
/
q28.sql
56 lines (56 loc) · 1.89 KB
/
q28.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
SELECT *
FROM (SELECT
avg(ss_list_price) B1_LP,
count(ss_list_price) B1_CNT,
count(DISTINCT ss_list_price) B1_CNTD
FROM store_sales
WHERE ss_quantity BETWEEN 0 AND 5
AND (ss_list_price BETWEEN 8 AND 8 + 10
OR ss_coupon_amt BETWEEN 459 AND 459 + 1000
OR ss_wholesale_cost BETWEEN 57 AND 57 + 20)) B1,
(SELECT
avg(ss_list_price) B2_LP,
count(ss_list_price) B2_CNT,
count(DISTINCT ss_list_price) B2_CNTD
FROM store_sales
WHERE ss_quantity BETWEEN 6 AND 10
AND (ss_list_price BETWEEN 90 AND 90 + 10
OR ss_coupon_amt BETWEEN 2323 AND 2323 + 1000
OR ss_wholesale_cost BETWEEN 31 AND 31 + 20)) B2,
(SELECT
avg(ss_list_price) B3_LP,
count(ss_list_price) B3_CNT,
count(DISTINCT ss_list_price) B3_CNTD
FROM store_sales
WHERE ss_quantity BETWEEN 11 AND 15
AND (ss_list_price BETWEEN 142 AND 142 + 10
OR ss_coupon_amt BETWEEN 12214 AND 12214 + 1000
OR ss_wholesale_cost BETWEEN 79 AND 79 + 20)) B3,
(SELECT
avg(ss_list_price) B4_LP,
count(ss_list_price) B4_CNT,
count(DISTINCT ss_list_price) B4_CNTD
FROM store_sales
WHERE ss_quantity BETWEEN 16 AND 20
AND (ss_list_price BETWEEN 135 AND 135 + 10
OR ss_coupon_amt BETWEEN 6071 AND 6071 + 1000
OR ss_wholesale_cost BETWEEN 38 AND 38 + 20)) B4,
(SELECT
avg(ss_list_price) B5_LP,
count(ss_list_price) B5_CNT,
count(DISTINCT ss_list_price) B5_CNTD
FROM store_sales
WHERE ss_quantity BETWEEN 21 AND 25
AND (ss_list_price BETWEEN 122 AND 122 + 10
OR ss_coupon_amt BETWEEN 836 AND 836 + 1000
OR ss_wholesale_cost BETWEEN 17 AND 17 + 20)) B5,
(SELECT
avg(ss_list_price) B6_LP,
count(ss_list_price) B6_CNT,
count(DISTINCT ss_list_price) B6_CNTD
FROM store_sales
WHERE ss_quantity BETWEEN 26 AND 30
AND (ss_list_price BETWEEN 154 AND 154 + 10
OR ss_coupon_amt BETWEEN 7326 AND 7326 + 1000
OR ss_wholesale_cost BETWEEN 7 AND 7 + 20)) B6
LIMIT 100;