1
+ pragma TablePathPrefix = " /Root/test/ds/" ;
2
+
3
+ -- NB: Subquerys
4
+
5
+ $blabla = (
6
+
7
+ select substring (cast(item .i_item_desc as string),0 ,30 ) itemdesc,item .i_item_sk item_sk,date_dim .d_date solddate
8
+
9
+ from store_sales as store_sales
10
+
11
+ cross join date_dim as date_dim
12
+
13
+ cross join item as item
14
+
15
+ where ss_sold_date_sk = d_date_sk
16
+
17
+ and ss_item_sk = i_item_sk
18
+
19
+ and d_year in (2000 ,2000 + 1 ,2000 + 2 ,2000 + 3 )
20
+
21
+ );
22
+
23
+ $frequent_ss_items =
24
+
25
+ (select itemdesc, item_sk, solddate,count (* ) cnt
26
+
27
+ from $blabla
28
+
29
+ group by itemdesc,item_sk,solddate
30
+
31
+ having count (* ) > 4 );
32
+
33
+
34
+
35
+ $max_store_sales =
36
+
37
+ (select max (csales) tpcds_cmax
38
+
39
+ from (select customer .c_customer_sk c_customer_sk,sum (ss_quantity* ss_sales_price) csales
40
+
41
+ from store_sales as store_sales
42
+
43
+ cross join customer as customer
44
+
45
+ cross join date_dim as date_dim
46
+
47
+ where ss_customer_sk = c_customer_sk
48
+
49
+ and ss_sold_date_sk = d_date_sk
50
+
51
+ and d_year in (2000 ,2000 + 1 ,2000 + 2 ,2000 + 3 )
52
+
53
+ group by customer .c_customer_sk ) x);
54
+
55
+
56
+
57
+ $best_ss_customer =
58
+
59
+ (select customer .c_customer_sk c_customer_sk,sum (ss_quantity* ss_sales_price) ssales
60
+
61
+ from store_sales as store_sales
62
+
63
+ cross join customer as customer
64
+
65
+ where ss_customer_sk = c_customer_sk
66
+
67
+ group by customer .c_customer_sk
68
+
69
+ having sum (ss_quantity* ss_sales_price) > (95 / 100 .0 ) * $max_store_sales);
70
+
71
+
72
+
73
+ -- start query 1 in stream 0 using template query23.tpl and seed 2031708268
74
+
75
+ select sum (sales)
76
+
77
+ from (select cs_quantity* cs_list_price sales
78
+
79
+ from catalog_sales as catalog_sales
80
+
81
+ cross join date_dim as date_dim
82
+
83
+ where d_year = 2000
84
+
85
+ and d_moy = 3
86
+
87
+ and cs_sold_date_sk = d_date_sk
88
+
89
+ and cs_item_sk in (select item_sk from $frequent_ss_items)
90
+
91
+ and cs_bill_customer_sk in (select c_customer_sk from $best_ss_customer)
92
+
93
+ union all
94
+
95
+ select ws_quantity* ws_list_price sales
96
+
97
+ from web_sales as web_sales
98
+
99
+ cross join date_dim as date_dim
100
+
101
+ where d_year = 2000
102
+
103
+ and d_moy = 3
104
+
105
+ and ws_sold_date_sk = d_date_sk
106
+
107
+ and ws_item_sk in (select item_sk from $frequent_ss_items)
108
+
109
+ and ws_bill_customer_sk in (select c_customer_sk from $best_ss_customer)) y
110
+
111
+ limit 100 ;
112
+
113
+
114
+
115
+ select c_last_name,c_first_name,sales
116
+
117
+ from (select customer .c_last_name c_last_name,customer .c_first_name c_first_name,sum (cs_quantity* cs_list_price) sales
118
+
119
+ from catalog_sales as catalog_sales
120
+
121
+ cross join customer as customer
122
+
123
+ cross join date_dim as date_dim
124
+
125
+ where d_year = 2000
126
+
127
+ and d_moy = 3
128
+
129
+ and cs_sold_date_sk = d_date_sk
130
+
131
+ and cs_item_sk in (select item_sk from $frequent_ss_items)
132
+
133
+ and cs_bill_customer_sk in (select c_customer_sk from $best_ss_customer)
134
+
135
+ and cs_bill_customer_sk = c_customer_sk
136
+
137
+ group by customer .c_last_name ,customer .c_first_name
138
+
139
+ union all
140
+
141
+ select customer .c_last_name c_last_name,customer .c_first_name c_first_name,sum (ws_quantity* ws_list_price) sales
142
+
143
+ from web_sales as web_sales
144
+
145
+ cross join customer as customer
146
+
147
+ cross join date_dim as date_dim
148
+
149
+ where d_year = 2000
150
+
151
+ and d_moy = 3
152
+
153
+ and ws_sold_date_sk = d_date_sk
154
+
155
+ and ws_item_sk in (select item_sk from $frequent_ss_items)
156
+
157
+ and ws_bill_customer_sk in (select c_customer_sk from $best_ss_customer)
158
+
159
+ and ws_bill_customer_sk = c_customer_sk
160
+
161
+ group by customer .c_last_name ,customer .c_first_name ) y
162
+
163
+ order by c_last_name,c_first_name,sales
164
+
165
+ limit 100 ;
166
+
167
+
168
+
169
+ -- end query 1 in stream 0 using template query23.tpl
0 commit comments