-
Notifications
You must be signed in to change notification settings - Fork 0
/
calcite_tests
464 lines (464 loc) · 75.2 KB
/
calcite_tests
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
SELECT UNIX_TIMESTAMP('12:34:56') FROM EMP AS EMP
SELECT UNIX_TIMESTAMP('12:34:56') FROM EMP AS EMP0
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 INTERSECT SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 INTERSECT SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT t10.EMPNO, t10.ENAME, t10.JOB, t10.MGR, t10.HIREDATE, t10.SAL, t10.COMM, t10.DEPTNO, t10.SLACKER FROM (SELECT EMP2.EMPNO, EMP2.ENAME, EMP2.JOB, EMP2.MGR, EMP2.HIREDATE, EMP2.SAL, EMP2.COMM, EMP2.DEPTNO, EMP2.SLACKER, COUNT(*) AS $f9 FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 GROUP BY EMP2.EMPNO, EMP2.ENAME, EMP2.JOB, EMP2.MGR, EMP2.HIREDATE, EMP2.SAL, EMP2.COMM, EMP2.DEPTNO, EMP2.SLACKER UNION ALL SELECT EMP3.EMPNO, EMP3.ENAME, EMP3.JOB, EMP3.MGR, EMP3.HIREDATE, EMP3.SAL, EMP3.COMM, EMP3.DEPTNO, EMP3.SLACKER, COUNT(*) AS $f9 FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 GROUP BY EMP3.EMPNO, EMP3.ENAME, EMP3.JOB, EMP3.MGR, EMP3.HIREDATE, EMP3.SAL, EMP3.COMM, EMP3.DEPTNO, EMP3.SLACKER UNION ALL SELECT EMP4.EMPNO, EMP4.ENAME, EMP4.JOB, EMP4.MGR, EMP4.HIREDATE, EMP4.SAL, EMP4.COMM, EMP4.DEPTNO, EMP4.SLACKER, COUNT(*) AS $f9 FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30 GROUP BY EMP4.EMPNO, EMP4.ENAME, EMP4.JOB, EMP4.MGR, EMP4.HIREDATE, EMP4.SAL, EMP4.COMM, EMP4.DEPTNO, EMP4.SLACKER) AS t10 GROUP BY t10.EMPNO, t10.ENAME, t10.JOB, t10.MGR, t10.HIREDATE, t10.SAL, t10.COMM, t10.DEPTNO, t10.SLACKER HAVING COUNT(*) = 3
SELECT R.Z + R.X FROM ( SELECT U.X + U.Y AS Z, U.X FROM ( SELECT * FROM (VALUES (10, 1), (30, 3)) AS T(X, Y) WHERE X + Y > 50) AS U) AS R
SELECT * FROM (VALUES (NULL)) AS t(EXPR$0) WHERE 1 = 0
SELECT * FROM ( SELECT * FROM (VALUES (10, 1), (30, 3)) AS T(X, Y) UNION ALL SELECT * FROM (VALUES (20, 2)) ) AS R WHERE X + Y > 30
SELECT * FROM (VALUES (30, 3)) AS T(X, Y)
SELECT DEPT.DEPTNO, DEPT.DEPTNO AS DEPTNO0 FROM DEPT AS DEPT ORDER BY DEPT.DEPTNO LIMIT 10000 OFFSET 1
SELECT DEPTNO, DEPTNO AS DEPTNO0 FROM (SELECT * FROM DEPT ORDER BY DEPTNO LIMIT 10000 OFFSET 1) t0 ORDER BY DEPTNO
SELECT DEPT.DEPTNO, DEPT.DEPTNO AS DEPTNO0 FROM DEPT AS DEPT ORDER BY DEPT.DEPTNO LIMIT 10000 OFFSET 1
SELECT DEPTNO, DEPTNO AS DEPTNO0 FROM (SELECT * FROM DEPT ORDER BY DEPTNO LIMIT 10000 OFFSET 1) t0 ORDER BY DEPTNO
SELECT DEPT.DEPTNO, DEPT.DEPTNO FROM DEPT AS DEPT ORDER BY DEPT.DEPTNO LIMIT 10000 OFFSET 1
SELECT DEPT0.DEPTNO, DEPT0.DEPTNO FROM DEPT AS DEPT0 ORDER BY DEPT0.DEPTNO LIMIT 10000 OFFSET 1
SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 7 AND EMP.EMPNO = 10 AND EMP.MGR IS NULL AND EMP.EMPNO = 10
SELECT 10 AS EMPNO, EMP0.ENAME, EMP0.JOB, NULL AS MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, 7 AS DEPTNO, EMP0.SLACKER FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 7 AND EMP0.MGR IS NULL AND EMP0.EMPNO = 10
SELECT * FROM EMP AS EMP WHERE EMP.EMPNO + 10 / 2 = 13
SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO + 5 = 13
SELECT EMP.ENAME FROM EMP AS EMP, DEPT AS DEPT, EMP AS EMP0 WHERE EMP.DEPTNO = DEPT.DEPTNO AND DEPT.DEPTNO = EMP0.DEPTNO
SELECT T0.ENAME FROM (SELECT * FROM EMP AS EMP1 WHERE EXISTS (SELECT 1 FROM DEPT AS DEPT0 WHERE EMP1.DEPTNO = DEPT0.DEPTNO)) AS T0 INNER JOIN (SELECT * FROM DEPT AS DEPT1 WHERE EXISTS (SELECT 1 FROM EMP AS EMP2 WHERE DEPT1.DEPTNO = EMP2.DEPTNO)) AS T1 ON T0.DEPTNO = T1.DEPTNO INNER JOIN EMP AS EMP3 ON T1.DEPTNO = EMP3.DEPTNO
SELECT t.ENAME, COUNT(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.ENAME
SELECT t6.ENAME, SUM(sum1) FROM (SELECT EMP1.ENAME, COUNT(EMP1.MGR) as sum1 FROM EMP AS EMP1 GROUP BY EMP1.ENAME UNION ALL SELECT EMP2.ENAME, COUNT(EMP2.MGR) FROM EMP AS EMP2 GROUP BY EMP2.ENAME) AS t6 GROUP BY t6.ENAME
SELECT COUNT(*), SUM(EMPNO) FROM EMP WHERE FALSE
SELECT * FROM (VALUES (0, NULL)) AS t(EXPR$0, EXPR$1)
SELECT 4, 2 + 3, MAX(5) FROM EMP AS EMP GROUP BY 4, 2 + 3
SELECT 4, 2 + 3, MAX(5) FROM EMP AS EMP0 GROUP BY 4
SELECT A + B AS X, B, A FROM (VALUES (10, 1), (30, 7), (20, 3)) AS T(A, B) WHERE A - B < 21
SELECT * FROM (VALUES (11, 1, 10), (23, 3, 20)) AS t(X, B, A)
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 EXCEPT SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 EXCEPT SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 EXCEPT SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 EXCEPT SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30
SELECT * FROM EMP AS EMP WHERE EXISTS (SELECT * FROM EMP AS EMP0 WHERE EMP.DEPTNO = EMP0.DEPTNO) AND NOT EXISTS (SELECT * FROM EMP AS EMP1 WHERE EMP1.JOB = EMP.JOB AND EMP1.SAL = 34)
SELECT EMP2.EMPNO, EMP2.ENAME, EMP2.JOB, EMP2.MGR, EMP2.HIREDATE, EMP2.SAL, EMP2.COMM, EMP2.DEPTNO, EMP2.SLACKER FROM EMP AS EMP2 INNER JOIN (SELECT EMP3.DEPTNO, 1 AS $f1 FROM EMP AS EMP3 GROUP BY EMP3.DEPTNO) AS t5 ON EMP2.DEPTNO = t5.DEPTNO LEFT JOIN (SELECT EMP4.JOB, 1 AS $f1 FROM EMP AS EMP4 WHERE EMP4.SAL = 34 GROUP BY EMP4.JOB) AS t10 ON EMP2.JOB = t10.JOB WHERE t10.$f1 IS NULL
SELECT * FROM (VALUES (30, 3)) AS T (X, Y) WHERE X > 30 EXCEPT SELECT * FROM (VALUES (20, 2)) EXCEPT SELECT * FROM (VALUES (40, 4))
SELECT * FROM (SELECT NULL AS X, NULL AS Y) AS t WHERE 1 = 0
SELECT t.EXPR$0 + t.EXPR$1 FROM (VALUES (10, 1), (20, 3)) AS t
SELECT * FROM (VALUES (11), (23)) AS t1
SELECT COUNT(*) AS C FROM EMP AS EMP WHERE EMP.DEPTNO = 10 GROUP BY EMP.DEPTNO, EMP.SAL
SELECT COUNT(*) AS C FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 10 GROUP BY EMP0.SAL
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EXISTS (SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) AND EMP.SAL < 100
SELECT EMP1.EMPNO FROM EMP AS EMP1, (SELECT 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20 GROUP BY TRUE) AS t4 WHERE EMP1.SAL < 100
SELECT * FROM (VALUES (10, 'x'), (20, 'y')) AS t WHERE t.EXPR$0 < 15
SELECT * FROM (VALUES (10, 'x')) AS t1
SELECT DEPT.DEPTNO FROM DEPT AS DEPT WHERE DEPT.DEPTNO = 7 AND DEPT.DEPTNO = 8
SELECT DEPTNO FROM (VALUES (NULL, NULL)) AS t(DEPTNO, NAME) WHERE 1 = 0
SELECT EMP.DEPTNO AS X, SUM(EMP.SAL), EMP.EMPNO AS Y FROM EMP AS EMP GROUP BY EMP.DEPTNO, EMP.EMPNO
SELECT EMP0.DEPTNO AS X, SUM(EMP0.SAL), EMP0.EMPNO AS Y FROM EMP AS EMP0 GROUP BY EMP0.EMPNO, EMP0.DEPTNO
SELECT EMP.ENAME FROM EMP AS EMP, DEPT AS DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO
SELECT EMP0.ENAME FROM EMP AS EMP0 INNER JOIN DEPT AS DEPT0 ON EMP0.DEPTNO = DEPT0.DEPTNO
SELECT 2, EMP.DEPTNO, EMP.JOB FROM EMP AS EMP UNION ALL SELECT 2, EMP0.DEPTNO, EMP0.JOB FROM EMP AS EMP0
SELECT 2, t6.DEPTNO, t6.JOB FROM (SELECT EMP1.DEPTNO, EMP1.JOB FROM EMP AS EMP1 UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB FROM EMP AS EMP2) AS t6
SELECT * FROM EMP WHERE EMPNO NOT IN (SELECT EMPNO FROM (SELECT ENAME, EMPNO, SAL AS R FROM EMP) AS t WHERE R > 2 AND EMP.ENAME = ENAME)
SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER FROM EMP LEFT JOIN (SELECT COUNT(*) AS c, COUNT(*) AS ck, ENAME FROM (SELECT ENAME, EMPNO, SAL AS R FROM EMP) AS t WHERE R > 2 GROUP BY ENAME) AS t3 ON EMP.ENAME = t3.ENAME LEFT JOIN (SELECT EMPNO, TRUE AS i, ENAME FROM (SELECT ENAME, EMPNO, SAL AS R FROM EMP) AS t4 WHERE R > 2) AS t6 ON EMP.EMPNO = t6.EMPNO AND EMP.ENAME = t6.ENAME WHERE t3.c = 0 OR (t6.i IS NOT NULL OR t3.ck < t3.c) IS NOT TRUE
SELECT * FROM (SELECT CASE WHEN EMP.SAL > 1000 THEN NULL ELSE FALSE END AS CASECOL FROM EMP AS EMP) AS t WHERE NOT t.CASECOL
SELECT * FROM (SELECT CASE WHEN EMP0.SAL > 1000 THEN NULL ELSE FALSE END AS CASECOL FROM EMP AS EMP0) AS t1 WHERE NOT t1.CASECOL
SELECT EMP.SAL, SUM(EMP.COMM), MIN(EMP.COMM), SUM(DISTINCT EMP.SAL) FROM EMP AS EMP GROUP BY EMP.SAL
SELECT t2.SAL, SUM(t2.sum1), MIN(t2.min1), SUM(t2.SAL) FROM (SELECT EMP0.SAL, SUM(EMP0.COMM) as sum1, MIN(EMP0.COMM) as min1 FROM EMP AS EMP0 GROUP BY EMP0.SAL) AS t2 GROUP BY t2.SAL
SELECT EMP.SAL FROM EMP AS EMP WHERE EMP.EMPNO NOT IN (SELECT DEPT.DEPTNO FROM DEPT AS DEPT WHERE EMP.JOB = DEPT.NAME)
SELECT EMP0.SAL FROM EMP AS EMP0 LEFT JOIN (SELECT DEPT0.NAME, COUNT(*) AS c, COUNT(DEPT0.DEPTNO) AS ck FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME) AS t4 ON EMP0.JOB = t4.NAME LEFT JOIN (SELECT DEPT1.DEPTNO, 1 AS i, DEPT1.NAME FROM DEPT AS DEPT1) AS t5 ON EMP0.EMPNO = t5.DEPTNO AND EMP0.JOB = t5.NAME WHERE NOT CASE WHEN t4.c = 0 THEN FALSE WHEN t5.i IS NOT NULL THEN TRUE WHEN t4.ck < t4.c THEN TRUE ELSE FALSE END
SELECT * FROM (SELECT t2.NAME, t2.DEPTNO FROM (SELECT DEPT.NAME, DEPT.DEPTNO, COUNT(*) FROM DEPT AS DEPT GROUP BY DEPT.NAME, DEPT.DEPTNO EXCEPT ALL SELECT DEPT0.NAME, DEPT0.DEPTNO, 1 FROM DEPT AS DEPT0) AS t2 EXCEPT ALL SELECT t7.NAME, t7.DEPTNO FROM (SELECT DEPT1.NAME, DEPT1.DEPTNO, 1 FROM DEPT AS DEPT1 EXCEPT ALL SELECT DEPT2.NAME, DEPT2.DEPTNO, COUNT(*) FROM DEPT AS DEPT2 GROUP BY DEPT2.NAME, DEPT2.DEPTNO) AS t7) AS t9 EXCEPT ALL SELECT DEPT3.NAME, DEPT3.DEPTNO FROM DEPT AS DEPT3
SELECT DEPT4.NAME, DEPT4.DEPTNO FROM DEPT AS DEPT4 GROUP BY DEPT4.NAME, DEPT4.DEPTNO EXCEPT ALL SELECT DEPT5.NAME, DEPT5.DEPTNO FROM DEPT AS DEPT5 EXCEPT ALL SELECT * FROM (SELECT DEPT6.NAME, DEPT6.DEPTNO FROM DEPT AS DEPT6 EXCEPT ALL SELECT DEPT7.NAME, DEPT7.DEPTNO FROM DEPT AS DEPT7 GROUP BY DEPT7.NAME, DEPT7.DEPTNO) AS t22 EXCEPT ALL SELECT DEPT8.NAME, DEPT8.DEPTNO FROM DEPT AS DEPT8
SELECT EMP.SAL FROM EMP AS EMP WHERE EMP.EMPNO IN (SELECT DEPT.DEPTNO FROM DEPT AS DEPT WHERE EMP.JOB = DEPT.NAME)
SELECT EMP0.SAL FROM EMP AS EMP0 INNER JOIN DEPT AS DEPT0 ON EMP0.JOB = DEPT0.NAME AND EMP0.EMPNO = DEPT0.DEPTNO
SELECT COUNT(1) FROM EMP WHERE CAST(NULL AS INTEGER) = 1
SELECT COUNT(*) FROM (SELECT NULL AS EMPNO, NULL AS ENAME, NULL AS JOB, NULL AS MGR, NULL AS HIREDATE, NULL AS SAL, NULL AS COMM, NULL AS DEPTNO, NULL AS SLACKER) AS t WHERE 1 = 0
SELECT EMP.DEPTNO, COUNT(DISTINCT EMP.ENAME), COUNT(DISTINCT EMP.JOB) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, COUNT(ENAME) FILTER (WHERE $g_1), COUNT(JOB) FILTER (WHERE $g_2) FROM (SELECT DEPTNO, ENAME, JOB, GROUPING(DEPTNO, ENAME, JOB) = 1 AS $g_1, GROUPING(DEPTNO, ENAME, JOB) = 2 AS $g_2 FROM EMP GROUP BY GROUPING SETS((ENAME, DEPTNO), (JOB, DEPTNO))) AS t1 GROUP BY DEPTNO
SELECT DEPT.DEPTNO, DEPT.NAME FROM DEPT AS DEPT INNER JOIN (SELECT EMP.DEPTNO AS DEPTNO9 FROM EMP AS EMP WHERE EMP.SAL > 100 GROUP BY EMP.DEPTNO) AS T1 ON DEPT.DEPTNO = T1.DEPTNO9
SELECT * FROM DEPT WHERE EXISTS (SELECT 1 FROM (SELECT DEPTNO AS DEPTNO9 FROM EMP WHERE SAL > 100) AS t0 WHERE DEPT.DEPTNO = t0.DEPTNO9)
SELECT T.ENAME FROM (SELECT EMP.ENAME, EMP.DEPTNO, EMP.SAL + 1 AS SALPLUS FROM EMP AS EMP) AS T WHERE T.DEPTNO IN (SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.SAL + 1 = EMP0.JOB)
SELECT t.ENAME FROM (SELECT ENAME, DEPTNO, SAL + 1 AS SALPLUS FROM EMP) AS t INNER JOIN (SELECT DEPTNO FROM EMP WHERE SAL + 1 = JOB GROUP BY DEPTNO) AS t2 ON t.DEPTNO = t2.DEPTNO
SELECT EMP.EMPNO FROM EMP AS EMP WHERE (EMP.EMPNO, EMP.DEPTNO) IN (SELECT EMP0.EMPNO, EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) OR EMP.SAL < 100
SELECT EMP1.EMPNO FROM EMP AS EMP1 LEFT JOIN (SELECT EMP2.EMPNO, EMP2.DEPTNO, 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20) AS t5 ON EMP1.EMPNO = t5.EMPNO AND EMP1.DEPTNO = t5.DEPTNO WHERE t5.i IS NOT NULL OR EMP1.SAL < 100
SELECT t0.ENAME, t0.SAL, t0.DEPTNO FROM (SELECT EMP.ENAME, EMP.SAL, EMP.DEPTNO FROM EMP AS EMP) AS t0 WHERE t0.SAL > 5000 GROUP BY t0.ENAME, t0.SAL, t0.DEPTNO
SELECT t4.ENAME, t4.SAL, t4.DEPTNO FROM (SELECT EMP0.ENAME, EMP0.SAL, EMP0.DEPTNO FROM EMP AS EMP0 GROUP BY EMP0.ENAME, EMP0.SAL, EMP0.DEPTNO HAVING EMP0.SAL > 5000) AS t4 GROUP BY t4.ENAME, t4.SAL, t4.DEPTNO
SELECT * FROM ANON AS t WHERE 1 + 2 > 3 + NULL
SELECT * FROM ANON AS t1 WHERE 1 + 2 > 3 + NULL
SELECT 1 FROM (SELECT EMP.DEPTNO, COUNT(*) FROM EMP AS EMP WHERE EMP.DEPTNO > 7 GROUP BY EMP.DEPTNO) AS t1 INNER JOIN EMP AS EMP0 ON t1.DEPTNO = EMP0.DEPTNO INNER JOIN EMP AS EMP1 ON EMP0.DEPTNO = EMP1.DEPTNO
SELECT 1 FROM (SELECT EMP2.DEPTNO, COUNT(*) FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7 GROUP BY EMP2.DEPTNO) AS t5 INNER JOIN (SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO > 7) AS t6 ON t5.DEPTNO = t6.DEPTNO INNER JOIN (SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO > 7) AS t7 ON t6.DEPTNO = t7.DEPTNO
SELECT EMP.MGR FROM EMP AS EMP WHERE EMP.MGR = 10
SELECT 10 AS MGR FROM EMP AS EMP0 WHERE EMP0.MGR = 10
SELECT * FROM EMP AS EMP WHERE EMP.SAL = 4 OR EMP.EMPNO NOT IN (SELECT DEPT.DEPTNO FROM DEPT AS DEPT)
SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER FROM EMP AS EMP0 LEFT JOIN (SELECT DEPT0.DEPTNO, 1 AS i FROM DEPT AS DEPT0) AS t2 ON EMP0.EMPNO = t2.DEPTNO WHERE EMP0.SAL = 4 OR NOT CASE WHEN t2.i IS NOT NULL THEN TRUE ELSE FALSE END
SELECT 1 FROM (SELECT EMP.COMM AS DEPTNO FROM EMP AS EMP WHERE EMP.DEPTNO > 7) AS t0 INNER JOIN EMP AS EMP0 ON t0.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM (SELECT EMP1.COMM AS DEPTNO FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 7) AS t3 INNER JOIN EMP AS EMP2 ON t3.DEPTNO = EMP2.DEPTNO
SELECT * FROM EMP AS EMP WHERE EXISTS (SELECT * FROM EMP AS EMP0 WHERE EMP.DEPTNO = EMP0.DEPTNO)
SELECT EMP1.EMPNO, EMP1.ENAME, EMP1.JOB, EMP1.MGR, EMP1.HIREDATE, EMP1.SAL, EMP1.COMM, EMP1.DEPTNO, EMP1.SLACKER FROM EMP AS EMP1 INNER JOIN (SELECT EMP2.DEPTNO FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO) AS t4 ON EMP1.DEPTNO = t4.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO > 7) AS t INNER JOIN EMP AS EMP0 ON t.DEPTNO = EMP0.DEPTNO INNER JOIN EMP AS EMP1 ON EMP0.DEPTNO = EMP1.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7) AS t1 INNER JOIN (SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO > 7) AS t2 ON t1.DEPTNO = t2.DEPTNO INNER JOIN (SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO > 7) AS t3 ON t2.DEPTNO = t3.DEPTNO
SELECT t.ENAME, COUNT(*) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.ENAME
SELECT t6.ENAME, SUM(count1) FROM (SELECT EMP1.ENAME, COUNT(*) as count1 FROM EMP AS EMP1 GROUP BY EMP1.ENAME UNION ALL SELECT EMP2.ENAME, COUNT(*) as count1 FROM EMP AS EMP2 GROUP BY EMP2.ENAME) AS t6 GROUP BY t6.ENAME
SELECT EMP.ENAME FROM EMP AS EMP, DEPT AS DEPT, EMP AS EMP0 WHERE EMP.DEPTNO = DEPT.DEPTNO AND DEPT.DEPTNO = EMP0.DEPTNO
SELECT EMP1.ENAME FROM EMP AS EMP1 INNER JOIN DEPT AS DEPT0 ON EMP1.DEPTNO = DEPT0.DEPTNO INNER JOIN EMP AS EMP2 ON DEPT0.DEPTNO = EMP2.DEPTNO
SELECT * FROM T AS T WHERE T.F0_C0 IN (SELECT T0.F1_C0 AS C0 FROM T AS T0)
SELECT T1.K0, T1.C1, T1.F1_A0, T1.F2_A0, T1.F0_C0, T1.F1_C0, T1.F0_C1, T1.F1_C2, T1.F2_C3 FROM T AS T1 INNER JOIN (SELECT T2.F1_C0 AS C0 FROM T AS T2 GROUP BY T2.F1_C0) AS t2 ON T1.F0_C0 = t2.C0
SELECT * FROM (VALUES (FALSE),(TRUE)) AS Q (COL1) WHERE NOT(COL1)
SELECT * FROM (SELECT FALSE AS COL1 UNION ALL SELECT TRUE AS COL1) AS t WHERE NOT COL1
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END FROM EMP AS EMP INNER JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END
SELECT COUNT(*), t.EXPR$1 FROM (SELECT ENAME, CASE WHEN SAL < 11 THEN 11 ELSE -1 * SAL END AS EXPR$1 FROM EMP) AS t INNER JOIN (SELECT ENAME FROM BONUS) AS t0 ON t.ENAME = t0.ENAME GROUP BY t.EXPR$1
SELECT EMP.JOB, MIN(EMP.SAL) AS MIN_SAL, MIN(EMP.DEPTNO) AS MIN_DEPTNO, SUM(EMP.SAL) + 1 AS SUM_SAL_PLUS, MAX(EMP.SAL) AS MAX_SAL, SUM(EMP.SAL) AS SUM_SAL_2, COUNT(*) AS COUNT_SAL, COUNT(EMP.MGR) AS COUNT_MGR FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.JOB = DEPT.NAME GROUP BY EMP.JOB, DEPT.NAME
SELECT t1.JOB, t1.MIN_SAL, t1.MIN_DEPTNO, t1.SUM_SAL_2 * t2.$f1 + 1 AS SUM_SAL_PLUS, t1.MAX_SAL, t1.SUM_SAL_2 * t2.$f1 AS SUM_SAL_2, t1.COUNT_SAL * t2.$f1 AS COUNT_SAL, t1.COUNT_MGR * t2.$f1 AS COUNT_MGR FROM (SELECT EMP0.JOB, MIN(EMP0.SAL) AS MIN_SAL, MIN(EMP0.DEPTNO) AS MIN_DEPTNO, SUM(EMP0.SAL) AS SUM_SAL_2, MAX(EMP0.SAL) AS MAX_SAL, COUNT(*) AS COUNT_SAL, COUNT(EMP0.MGR) AS COUNT_MGR FROM EMP AS EMP0 GROUP BY EMP0.JOB) AS t1 INNER JOIN (SELECT DEPT0.NAME, COUNT(*) AS $f1 FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME) AS t2 ON t1.JOB = t2.NAME
SELECT 1 FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO > 7) AS t INNER JOIN EMP AS EMP0 ON t.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 7) AS t1 INNER JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7) AS t2 ON t1.DEPTNO = t2.DEPTNO
SELECT t.ENAME, AVG(t.EMPNO) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.ENAME
SELECT t4.ENAME, AVG(t4.EMPNO) FROM (SELECT EMP1.ENAME, EMP1.EMPNO FROM EMP AS EMP1 UNION ALL SELECT EMP2.ENAME, EMP2.EMPNO FROM EMP AS EMP2) AS t4 GROUP BY t4.ENAME
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END FROM EMP AS EMP FULL JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END
SELECT COUNT(*), t2.expr1 FROM (SELECT EMP0.ENAME, CASE WHEN EMP0.SAL < 11 THEN -1 * EMP0.SAL ELSE EMP0.SAL END AS expr1 FROM EMP AS EMP0) AS t2 FULL JOIN (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY t2.expr1
SELECT * FROM (SELECT UPPER(SUBSTRING(X FROM 1 FOR 2) || SUBSTRING(X FROM 3)) AS U, SUBSTRING(X FROM 1 FOR 1) AS S FROM (SELECT 'table' AS X FROM (VALUES (TRUE)) AS T0 UNION SELECT 'view' FROM (VALUES (TRUE)) AS T1 UNION SELECT 'foreign table' FROM (VALUES (TRUE)) AS T2) AS T3) AS T4 WHERE U = 'TABLE'
SELECT 'TABLE' AS U, 't' AS S FROM (VALUES (TRUE)) AS t(EXPR$0)
SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 7 AND EMP.DEPTNO = 8 AND EMP.EMPNO = 10 AND EMP.MGR IS NULL AND EMP.EMPNO = 10
SELECT 10 AS EMPNO, ENAME, JOB, CAST(NULL AS INTEGER) AS MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER) WHERE 1 = 0
SELECT * FROM (SELECT * FROM (SELECT NULL AS N FROM EMP AS EMP) AS t WHERE t.N IS NULL AND t.N IS NULL) AS t0 WHERE t0.N IS NULL
SELECT NULL AS N FROM EMP AS EMP0
SELECT t1.DEPTNO, COUNT(*) FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 UNION ALL SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO > 20) AS t1 GROUP BY t1.DEPTNO
SELECT t10.DEPTNO, SUM(t10.count1) FROM (SELECT EMP1.DEPTNO, COUNT(*) as count1 FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 10 GROUP BY EMP1.DEPTNO UNION ALL SELECT EMP2.DEPTNO, COUNT(*) as count1 FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 20 GROUP BY EMP2.DEPTNO) AS t10 GROUP BY t10.DEPTNO
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EMP.EMPNO > 10 AND EMP.EMPNO <= 10
SELECT EMPNO FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER) WHERE 1 = 0
SELECT t.DEPTNO, t.JOB, SUM(t.EMPNO), COUNT(*), MIN(t.DEPTNO), MAX(t.EMPNO) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t6.DEPTNO, t6.JOB, SUM(t6.sum1), SUM(t6.count1), MIN(t6.min1), MAX(t6.max1) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, SUM(EMP1.EMPNO) as sum1, COUNT(*) as count1, MIN(EMP1.DEPTNO) as min1, MAX(EMP1.EMPNO) as max1 FROM EMP AS EMP1 GROUP BY EMP1.DEPTNO, EMP1.JOB UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, SUM(EMP2.EMPNO) as sum1, COUNT(*) as count1, MIN(EMP2.DEPTNO) as min1, MAX(EMP2.EMPNO) as max1 FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO, EMP2.JOB) AS t6 GROUP BY t6.DEPTNO, t6.JOB
SELECT EMP.ENAME FROM EMP AS EMP, DEPT AS DEPT, EMP AS EMP0 WHERE EMP.DEPTNO = DEPT.DEPTNO AND EMP.EMPNO = EMP0.EMPNO
SELECT EMP1.ENAME FROM EMP AS EMP1 INNER JOIN DEPT AS DEPT0 ON EMP1.DEPTNO = DEPT0.DEPTNO INNER JOIN EMP AS EMP2 ON EMP1.EMPNO = EMP2.EMPNO INNER JOIN DEPT AS DEPT1 ON EMP1.DEPTNO = DEPT1.DEPTNO INNER JOIN EMP AS EMP3 ON EMP1.EMPNO = EMP3.EMPNO
SELECT 1 FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO
SELECT 1 FROM EMP AS EMP0, DEPT AS DEPT0 WHERE EMP0.DEPTNO = DEPT0.DEPTNO
SELECT t.NAME, SUM(EMP.SAL) AS SUM_SAL, COUNT(*) AS C FROM EMP AS EMP INNER JOIN (SELECT DEPT.NAME FROM DEPT AS DEPT GROUP BY DEPT.NAME) AS t ON EMP.JOB = t.NAME GROUP BY t.NAME
SELECT t2.NAME, t1.SUM_SAL, t1.C FROM (SELECT EMP0.JOB, SUM(EMP0.SAL) AS SUM_SAL, COUNT(*) AS C FROM EMP AS EMP0 GROUP BY EMP0.JOB) AS t1 INNER JOIN (SELECT DEPT0.NAME FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME) AS t2 ON t1.JOB = t2.NAME
SELECT 1 FROM EMP AS EMP FULL JOIN EMP AS EMP0 ON EMP.DEPTNO = EMP0.DEPTNO WHERE EMP.DEPTNO > 7 AND EMP0.DEPTNO > 9
SELECT 1 FROM EMP AS EMP1 FULL JOIN EMP AS EMP2 ON EMP1.DEPTNO = EMP2.DEPTNO WHERE EMP1.DEPTNO > 7 AND EMP2.DEPTNO > 9
SELECT EMP.SAL FROM EMP AS EMP WHERE EMP.EMPNO IN (SELECT DEPT.DEPTNO FROM DEPT AS DEPT WHERE EMP.JOB = DEPT.NAME) AND EMP.EMPNO IN (SELECT EMP0.EMPNO FROM EMP AS EMP0 WHERE EMP.ENAME = EMP0.ENAME)
SELECT EMP1.SAL FROM EMP AS EMP1 INNER JOIN DEPT AS DEPT0 ON EMP1.JOB = DEPT0.NAME AND EMP1.EMPNO = DEPT0.DEPTNO INNER JOIN (SELECT EMP2.EMPNO, EMP2.ENAME FROM EMP AS EMP2) AS t5 ON EMP1.ENAME = t5.ENAME AND EMP1.EMPNO = t5.EMPNO
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END FROM BONUS AS BONUS LEFT JOIN EMP AS EMP ON BONUS.ENAME = EMP.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END
SELECT COUNT(*), t3.expr1 FROM (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t2 LEFT JOIN (SELECT EMP0.ENAME, CASE WHEN EMP0.SAL < 11 THEN -1 * EMP0.SAL ELSE EMP0.SAL END AS expr1 FROM EMP AS EMP0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY t3.expr1
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EXISTS (SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20)
SELECT EMP1.EMPNO FROM EMP AS EMP1, (SELECT 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20 GROUP BY TRUE) AS t4
SELECT EMP.DEPTNO, MAX(EMP.MGR) FROM EMP AS EMP GROUP BY 42 + 24, EMP.DEPTNO
SELECT EMP0.DEPTNO, MAX(EMP0.MGR) FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO
SELECT t.ENAME, SUM(t.EMPNO), COUNT(*), MIN(t.DEPTNO), MAX(t.EMPNO) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.ENAME
SELECT t6.ENAME, SUM(t6.sum1), SUM(t6.count1), MIN(t6.min1), MAX(t6.max1) FROM (SELECT EMP1.ENAME, SUM(EMP1.EMPNO) as sum1, COUNT(*) as count1, MIN(EMP1.DEPTNO) as min1, MAX(EMP1.EMPNO) as max1 FROM EMP AS EMP1 GROUP BY EMP1.ENAME UNION ALL SELECT EMP2.ENAME, SUM(EMP2.EMPNO) as sum1, COUNT(*) as count1, MIN(EMP2.DEPTNO) as min1, MAX(EMP2.EMPNO) as max1 FROM EMP AS EMP2 GROUP BY EMP2.ENAME) AS t6 GROUP BY t6.ENAME
SELECT * FROM (SELECT EMP.ENAME, RANK() OVER (PARTITION BY EMP.DEPTNO ORDER BY EMP.SAL RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS R FROM EMP AS EMP) AS t WHERE t.R < 2
SELECT * FROM (SELECT EMP0.ENAME, RANK() OVER (PARTITION BY EMP0.DEPTNO ORDER BY EMP0.SAL RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS R FROM EMP AS EMP0) AS t1 WHERE t1.R < 2
SELECT t.DEPTNO, t.JOB, SUM(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t6.DEPTNO, t6.JOB, SUM(t6.sum1) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, SUM(EMP1.MGR) as sum1 FROM EMP AS EMP1 GROUP BY EMP1.DEPTNO, EMP1.JOB UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, SUM(EMP2.MGR) as sum1 FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO, EMP2.JOB) AS t6 GROUP BY t6.DEPTNO, t6.JOB
SELECT t.NAME FROM (SELECT * FROM DEPT AS DEPT WHERE DEPT.DEPTNO = 10) AS t WHERE t.DEPTNO = 10
SELECT DEPT0.NAME FROM DEPT AS DEPT0 WHERE DEPT0.DEPTNO = 10
SELECT EMP.DEPTNO, EMP.JOB, COUNT(DISTINCT EMP.ENAME) FROM EMP AS EMP GROUP BY EMP.DEPTNO, EMP.JOB
SELECT DEPTNO, JOB, COUNT(ENAME) FROM (SELECT DEPTNO, JOB, ENAME FROM EMP GROUP BY DEPTNO, JOB, ENAME) AS t0 GROUP BY DEPTNO, JOB
SELECT EMP.DEPTNO, EMP.JOB, COUNT(DISTINCT EMP.ENAME), SUM(EMP.SAL) FROM EMP AS EMP GROUP BY EMP.DEPTNO, EMP.JOB
SELECT DEPTNO, JOB, COUNT(ENAME) FILTER (WHERE $g_0), CAST(MIN(EXPR$3) FILTER (WHERE $g_1) AS INTEGER) FROM (SELECT DEPTNO, JOB, ENAME, SUM(SAL) AS EXPR$3, GROUPING(DEPTNO, JOB, ENAME) = 0 AS $g_0, GROUPING(DEPTNO, JOB, ENAME) = 1 AS $g_1 FROM EMP GROUP BY GROUPING SETS((DEPTNO, JOB, ENAME), (DEPTNO, JOB))) AS t1 GROUP BY DEPTNO, JOB
SELECT t.SAL FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t
SELECT EMP1.SAL FROM EMP AS EMP1 UNION ALL SELECT EMP2.SAL FROM EMP AS EMP2
SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 EXCEPT SELECT * FROM (SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20 EXCEPT SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30) AS t2
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 EXCEPT SELECT * FROM (SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 EXCEPT SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30) AS t7
SELECT DEPT.NAME AS DNAME, COUNT(*) AS C FROM DEPT AS DEPT GROUP BY DEPT.NAME HAVING DEPT.NAME = 'Charlie'
SELECT t2.DNAME, COUNT(*) AS C FROM (SELECT DEPT0.NAME AS DNAME FROM DEPT AS DEPT0) AS t2 WHERE t2.DNAME = 'Charlie' GROUP BY t2.DNAME
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END FROM EMP AS EMP FULL JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END
SELECT COUNT(*), CASE WHEN t2.expr1 THEN 11 ELSE t2.expr2 END FROM (SELECT EMP0.ENAME, EMP0.SAL < 11 AS expr1, -1 * EMP0.SAL AS expr2 FROM EMP AS EMP0) AS t2 FULL JOIN (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY CASE WHEN t2.expr1 THEN 11 ELSE t2.expr2 END
SELECT * FROM ( SELECT * FROM EMP WHERE FALSE) AS E JOIN DEPT AS D ON E.DEPTNO = D.DEPTNO
SELECT * FROM (SELECT NULL AS EMPNO, NULL AS ENAME, NULL AS JOB, NULL AS MGR, NULL AS HIREDATE, NULL AS SAL, NULL AS COMM, NULL AS DEPTNO, NULL AS SLACKER, NULL AS DEPTNO0, NULL AS NAME) AS t WHERE 1 = 0
SELECT * FROM EMP AS EMP WHERE FALSE ORDER BY EMP.DEPTNO
SELECT * FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER) WHERE 1 = 0
SELECT EMP.SAL, SUM(EMP.COMM), MIN(DISTINCT EMP.COMM), SUM(DISTINCT EMP.SAL) FROM EMP AS EMP GROUP BY EMP.SAL
SELECT SAL, SUM(EXPR$1), MIN(EXPR$2), SUM(SAL) FROM (SELECT SAL, SUM(COMM) AS EXPR$1, MIN(COMM) AS EXPR$2 FROM EMP GROUP BY SAL) AS t0 GROUP BY SAL
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EMP.EMPNO = 10 AND EMP.EMPNO IS NULL
SELECT EMPNO FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER) WHERE 1 = 0
SELECT 1 FROM EMP AS EMP INNER JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO > 7) AS t ON EMP.DEPTNO = t.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 7) AS t1 INNER JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7) AS t2 ON t1.DEPTNO = t2.DEPTNO
SELECT t.DEPTNO, t.JOB, COUNT(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t6.DEPTNO, t6.JOB, SUM(t6.count1) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, COUNT(EMP1.MGR) as count1 FROM EMP AS EMP1 GROUP BY EMP1.DEPTNO, EMP1.JOB UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, COUNT(EMP2.MGR) as count1 FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO, EMP2.JOB) AS t6 GROUP BY t6.DEPTNO, t6.JOB
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END FROM EMP AS EMP RIGHT JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END
SELECT COUNT(*), t2.expr1 FROM (SELECT EMP0.ENAME, CASE WHEN EMP0.SAL < 11 THEN -1 * EMP0.SAL ELSE EMP0.SAL END AS expr1 FROM EMP AS EMP0) AS t2 RIGHT JOIN (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY t2.expr1
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END FROM BONUS AS BONUS RIGHT JOIN EMP AS EMP ON BONUS.ENAME = EMP.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END
SELECT COUNT(*), t3.expr1 FROM (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t2 RIGHT JOIN (SELECT EMP0.ENAME, CASE WHEN EMP0.SAL < 11 THEN -1 * EMP0.SAL ELSE EMP0.SAL END AS expr1 FROM EMP AS EMP0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY t3.expr1
SELECT DEPT.DEPTNO, DEPT.NAME FROM DEPT AS DEPT RIGHT JOIN (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.SAL > 100 GROUP BY EMP.DEPTNO) AS t1 ON DEPT.DEPTNO = t1.DEPTNO
SELECT DEPT0.DEPTNO, DEPT0.NAME FROM DEPT AS DEPT0 RIGHT JOIN (SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.SAL > 100 GROUP BY EMP0.DEPTNO) AS t5 ON DEPT0.DEPTNO = t5.DEPTNO
SELECT 1 FROM DEPT AS DEPT FULL JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO WHERE EMP.SAL > 100
SELECT 1 FROM DEPT AS DEPT0 RIGHT JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.SAL > 100) AS t1 ON DEPT0.DEPTNO = t1.DEPTNO
SELECT DEPT.NAME AS C1 FROM DEPT AS DEPT WHERE DEPT.NAME > 'b' GROUP BY DEPT.NAME HAVING DEPT.NAME > 'c' AND (COUNT(*) > 30 OR DEPT.NAME < 'z')
SELECT t5.C1 FROM (SELECT DEPT0.NAME AS C1 FROM DEPT AS DEPT0 WHERE DEPT0.NAME > 'b') AS t5 WHERE t5.C1 > 'c' GROUP BY t5.C1 HAVING COUNT(*) > 30 OR t5.C1 < 'z'
SELECT COUNT(*) FROM EMP JOIN DEPT ON JOB = NAME
SELECT COALESCE(SUM(t.EXPR$0 * t0.EXPR$0), 0) FROM (SELECT JOB, COUNT(*) AS EXPR$0 FROM EMP GROUP BY JOB) AS t INNER JOIN (SELECT NAME, COUNT(*) AS EXPR$0 FROM DEPT GROUP BY NAME) AS t0 ON t.JOB = t0.NAME
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END FROM EMP AS EMP LEFT JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END
SELECT COUNT(*), t2.expr1 FROM (SELECT EMP0.ENAME, CASE WHEN EMP0.SAL < 11 THEN 11 ELSE -1 * EMP0.SAL END AS expr1 FROM EMP AS EMP0) AS t2 LEFT JOIN (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY t2.expr1
SELECT * FROM (SELECT DEPT.NAME FROM DEPT AS DEPT UNION ALL SELECT DEPT0.NAME FROM DEPT AS DEPT0) AS T1 ORDER BY T1.NAME FETCH NEXT 10 ROWS ONLY
SELECT * FROM ((SELECT NAME FROM DEPT ORDER BY NAME FETCH NEXT 10 ROWS ONLY) UNION ALL (SELECT NAME FROM DEPT ORDER BY NAME FETCH NEXT 10 ROWS ONLY)) AS T1 ORDER BY NAME FETCH NEXT 10 ROWS ONLY
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EMP.EMPNO = 10 AND NOT EMP.EMPNO = 10
SELECT EMPNO FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER) WHERE 1 = 0
SELECT t.ENAME, TRIM( BOTH ' ' FROM t.JOB ), t.SAL * 2, t.DEPTNO FROM ( SELECT EMP.ENAME, TRIM( BOTH ' ' FROM EMP.JOB ) AS JOB, EMP.SAL * 2 AS SAL, EMP.DEPTNO FROM EMP AS EMP ) AS t, DEPT AS DEPT WHERE t.DEPTNO = DEPT.DEPTNO
SELECT t2.ENAME, TRIM( BOTH ' ' FROM t2.JOB ), t2.SAL * 2, t2.DEPTNO FROM ( SELECT EMP0.ENAME, TRIM( BOTH ' ' FROM EMP0.JOB ) AS JOB, EMP0.SAL * 2 AS SAL, EMP0.DEPTNO FROM EMP AS EMP0 INNER JOIN DEPT AS DEPT0 ON EMP0.DEPTNO = DEPT0.DEPTNO ) AS t2 INNER JOIN DEPT AS DEPT1 ON t2.DEPTNO = DEPT1.DEPTNO
SELECT * FROM (SELECT EMP.ENAME, (RANK() OVER (PARTITION BY EMP.DEPTNO ORDER BY EMP.SAL RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) + 1 AS R FROM EMP AS EMP) AS t WHERE t.R < 2
SELECT * FROM (SELECT EMP0.ENAME, (RANK() OVER (PARTITION BY EMP0.DEPTNO ORDER BY EMP0.SAL RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) + 1 AS R FROM EMP AS EMP0) AS t1 WHERE t1.R < 2
SELECT CASE WHEN 1 = 2 THEN t0.EXPR$0 ELSE 2 END FROM (VALUES (1)) AS t LEFT JOIN (VALUES (1)) AS t0(EXPR$0) ON TRUE
SELECT 2 FROM (VALUES (1)) AS t2 LEFT JOIN (VALUES (1)) AS t3 ON TRUE
SELECT SUM(t.c) FROM ANON AS t
SELECT SUM(t1.c) FROM ANON AS t1
SELECT * FROM EMP AS EMP LEFT JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO ORDER BY EMP.SAL FETCH NEXT 10 ROWS ONLY
SELECT * FROM (SELECT * FROM EMP AS EMP0 ORDER BY EMP0.SAL FETCH NEXT 10 ROWS ONLY) AS t2 LEFT JOIN DEPT AS DEPT0 ON t2.DEPTNO = DEPT0.DEPTNO ORDER BY t2.SAL FETCH NEXT 10 ROWS ONLY
SELECT EMP.* FROM EMP AS EMP RIGHT JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO ORDER BY DEPT.NAME
SELECT EMP0.* FROM EMP AS EMP0 RIGHT JOIN (SELECT * FROM DEPT AS DEPT0 ORDER BY DEPT0.NAME) AS t0 ON EMP0.DEPTNO = t0.DEPTNO ORDER BY t0.NAME
SELECT * FROM EMP AS EMP LEFT JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO ORDER BY EMP.SAL, DEPT.NAME LIMIT 10
SELECT * FROM EMP AS EMP0 LEFT JOIN DEPT AS DEPT0 ON EMP0.DEPTNO = DEPT0.DEPTNO ORDER BY EMP0.SAL, DEPT0.NAME LIMIT 10
SELECT EMP.* FROM EMP AS EMP RIGHT JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO ORDER BY DEPT.NAME
SELECT EMP0.* FROM EMP AS EMP0 RIGHT JOIN (SELECT * FROM DEPT AS DEPT0 ORDER BY DEPT0.NAME) AS t0 ON EMP0.DEPTNO = t0.DEPTNO ORDER BY t0.NAME
SELECT * FROM EMP AS EMP RIGHT JOIN (SELECT * FROM DEPT AS DEPT LIMIT 10) AS t ON EMP.DEPTNO = t.DEPTNO LIMIT 10
SELECT * FROM EMP AS EMP0 RIGHT JOIN (SELECT * FROM DEPT AS DEPT0 LIMIT 10) AS t1 ON EMP0.DEPTNO = t1.DEPTNO LIMIT 10
SELECT * FROM (SELECT DEPT.NAME, DEPT.DEPTNO FROM DEPT AS DEPT UNION ALL SELECT t4.NAME, t4.DEPTNO FROM (SELECT DEPT0.NAME, DEPT0.DEPTNO, COUNT(*) FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME, DEPT0.DEPTNO UNION ALL SELECT DEPT1.NAME, DEPT1.DEPTNO, COUNT(*) FROM DEPT AS DEPT1 GROUP BY DEPT1.NAME, DEPT1.DEPTNO) AS t4) AS t6 UNION ALL SELECT DEPT2.NAME, DEPT2.DEPTNO FROM DEPT AS DEPT2
SELECT DEPT3.NAME, DEPT3.DEPTNO FROM DEPT AS DEPT3 UNION ALL SELECT DEPT4.NAME, DEPT4.DEPTNO FROM DEPT AS DEPT4 GROUP BY DEPT4.NAME, DEPT4.DEPTNO UNION ALL SELECT DEPT5.NAME, DEPT5.DEPTNO FROM DEPT AS DEPT5 GROUP BY DEPT5.NAME, DEPT5.DEPTNO UNION ALL SELECT DEPT6.NAME, DEPT6.DEPTNO FROM DEPT AS DEPT6
SELECT DEPT.DEPTNO, DEPT.NAME FROM DEPT AS DEPT INNER JOIN (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.SAL > 100 GROUP BY EMP.DEPTNO) AS T1 ON DEPT.DEPTNO = T1.DEPTNO
SELECT * FROM DEPT WHERE EXISTS (SELECT 1 FROM (SELECT DEPTNO FROM EMP WHERE SAL > 100) AS t0 WHERE DEPT.DEPTNO = t0.DEPTNO)
SELECT S.DEPTNO FROM (SELECT * FROM DEPT WHERE EXISTS ( SELECT * FROM EMP WHERE EMP.DEPTNO = DEPT.DEPTNO AND EMP.SAL > 100)) S JOIN ACCOUNT ON S.DEPTNO = ACCOUNT.ACCTNO
SELECT t.DEPTNO FROM (SELECT DEPTNO FROM DEPT WHERE EXISTS (SELECT 1 FROM (SELECT DEPTNO FROM (SELECT SAL, DEPTNO FROM EMP) AS t0 WHERE SAL > 100) AS t2 WHERE DEPT.DEPTNO = t2.DEPTNO)) AS t INNER JOIN (SELECT ACCTNO FROM ACCOUNT) AS t3 ON t.DEPTNO = t3.ACCTNO
SELECT 1 FROM EMP AS EMP INNER JOIN EMP AS EMP0 ON EMP.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM EMP AS EMP1 INNER JOIN EMP AS EMP2 ON EMP1.DEPTNO = EMP2.DEPTNO
SELECT A + B AS X, B, A FROM (VALUES (10, 1), (30, 7)) AS T(A, B) WHERE A - B < 0
SELECT * FROM (VALUES (NULL, NULL, NULL)) AS t(X, B, A) WHERE 1 = 0
SELECT EMP.EMPNO + EMP.DEPTNO FROM EMP AS EMP WHERE EMP.SAL = 10 * EMP.COMM AND UPPER(EMP.ENAME) = 'FOO'
SELECT t1.EMPNO + t1.DEPTNO FROM (SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO FROM EMP AS EMP0) AS t1 WHERE t1.SAL = 10 * t1.COMM AND UPPER(t1.ENAME) = 'FOO'
SELECT EMP.DEPTNO, SUM(EMP.COMM), MIN(EMP.COMM), SUM(DISTINCT EMP.SAL) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, SUM(EXPR$1), MIN(EXPR$2), SUM(SAL) FROM (SELECT DEPTNO, SAL, SUM(COMM) AS EXPR$1, MIN(COMM) AS EXPR$2 FROM EMP GROUP BY DEPTNO, SAL) AS t0 GROUP BY DEPTNO
SELECT EMP.DEPTNO AS X, SUM(EMP.SAL), EMP.EMPNO AS Y FROM EMP AS EMP GROUP BY EMP.DEPTNO, EMP.EMPNO
SELECT EMP0.DEPTNO AS X, SUM(EMP0.SAL), EMP0.EMPNO AS Y FROM EMP AS EMP0 GROUP BY EMP0.EMPNO, EMP0.DEPTNO
SELECT DEPT.* FROM DEPT AS DEPT INNER JOIN (SELECT EMP.DEPTNO FROM EMP AS EMP) AS t ON DEPT.DEPTNO = t.DEPTNO WHERE DEPT.DEPTNO <= 10
SELECT t1.* FROM (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.DEPTNO <= 10) AS t1 INNER JOIN (SELECT EMP0.DEPTNO FROM EMP AS EMP0) AS t2 ON t1.DEPTNO = t2.DEPTNO
SELECT T.ENAME, MIN(T.EMPNO) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS T GROUP BY T.ENAME
SELECT ENAME, MIN(EXPR$1) FROM (SELECT ENAME, MIN(EMPNO) AS EXPR$1 FROM EMP GROUP BY ENAME UNION ALL SELECT ENAME, MIN(EMPNO) AS EXPR$1 FROM EMP GROUP BY ENAME) AS t3 GROUP BY ENAME
SELECT T1.DEPTNO, T1.JOB, SUM(T1.U) FROM (SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER, 2 AS U FROM EMP AS EMP UNION ALL SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER, 3 AS U FROM EMP AS EMP0) AS T1 GROUP BY T1.DEPTNO, T1.JOB
SELECT DEPTNO, JOB, SUM(EXPR$2) FROM (SELECT DEPTNO, JOB, SUM(2) AS EXPR$2 FROM EMP GROUP BY DEPTNO, JOB UNION ALL SELECT DEPTNO, JOB, SUM(3) AS EXPR$2 FROM EMP GROUP BY DEPTNO, JOB) AS t3 GROUP BY DEPTNO, JOB
SELECT DEPT.DEPTNO, DEPT.NAME, COUNT(*) AS C FROM DEPT AS DEPT GROUP BY DEPT.DEPTNO, DEPT.NAME HAVING DEPT.NAME = 'Charlie'
SELECT DEPT0.DEPTNO, DEPT0.NAME, COUNT(*) AS C FROM DEPT AS DEPT0 GROUP BY DEPT0.DEPTNO, DEPT0.NAME HAVING DEPT0.NAME = 'Charlie'
SELECT DEPT.NAME AS DNAME, DEPT.DEPTNO AS DDEPTNO, COUNT(*) AS C FROM DEPT AS DEPT GROUP BY DEPT.NAME, DEPT.DEPTNO HAVING DEPT.NAME = 'Charlie'
SELECT t2.DNAME, t2.DDEPTNO, COUNT(*) AS C FROM (SELECT DEPT0.NAME AS DNAME, DEPT0.DEPTNO AS DDEPTNO FROM DEPT AS DEPT0) AS t2 WHERE t2.DNAME = 'Charlie' GROUP BY t2.DNAME, t2.DDEPTNO
SELECT 1 FROM (SELECT * FROM (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.DEPTNO > 7 UNION ALL SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.DEPTNO > 10) AS t3 UNION ALL SELECT EMP1.DEPTNO FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 1) AS t6 INNER JOIN EMP AS EMP2 ON t6.DEPTNO = EMP2.DEPTNO
SELECT 1 FROM (SELECT * FROM (SELECT EMP3.DEPTNO FROM EMP AS EMP3 WHERE EMP3.DEPTNO > 7 UNION ALL SELECT EMP4.DEPTNO FROM EMP AS EMP4 WHERE EMP4.DEPTNO > 10) AS t12 UNION ALL SELECT EMP5.DEPTNO FROM EMP AS EMP5 WHERE EMP5.DEPTNO > 1) AS t15 INNER JOIN (SELECT * FROM EMP AS EMP6 WHERE EMP6.DEPTNO > 7 OR EMP6.DEPTNO > 10 OR EMP6.DEPTNO > 1) AS t16 ON t15.DEPTNO = t16.DEPTNO
SELECT DEPT.NAME, STDDEV_POP(DEPT.DEPTNO), AVG(DEPT.DEPTNO), STDDEV_SAMP(DEPT.DEPTNO), VAR_POP(DEPT.DEPTNO), VAR_SAMP(DEPT.DEPTNO) FROM DEPT AS DEPT GROUP BY DEPT.NAME
SELECT DEPT0.NAME, POWER((SUM(DEPT0.DEPTNO * DEPT0.DEPTNO) - SUM(DEPT0.DEPTNO) * SUM(DEPT0.DEPTNO) / COUNT(*)) / COUNT(*), 0.5), SUM(DEPT0.DEPTNO) / COUNT(*), POWER((SUM(DEPT0.DEPTNO * DEPT0.DEPTNO) - SUM(DEPT0.DEPTNO) * SUM(DEPT0.DEPTNO) / COUNT(*)) / CASE WHEN COUNT(*) = 1 THEN NULL ELSE COUNT(*) - 1 END, 0.5), (SUM(DEPT0.DEPTNO * DEPT0.DEPTNO) - SUM(DEPT0.DEPTNO) * SUM(DEPT0.DEPTNO) / COUNT(*)) / COUNT(*), (SUM(DEPT0.DEPTNO * DEPT0.DEPTNO) - SUM(DEPT0.DEPTNO) * SUM(DEPT0.DEPTNO) / COUNT(*)) / CASE WHEN COUNT(*) = 1 THEN NULL ELSE COUNT(*) - 1 END FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME
SELECT EMP.DEPTNO, MAX(EMP.MGR) FROM EMP AS EMP GROUP BY EMP.DEPTNO, 4
SELECT EMP0.DEPTNO, MAX(EMP0.MGR) FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 INTERSECT SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 INTERSECT ALL SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT t8.EMPNO, t8.ENAME, t8.JOB, t8.MGR, t8.HIREDATE, t8.SAL, t8.COMM, t8.DEPTNO, t8.SLACKER FROM (SELECT EMP2.EMPNO, EMP2.ENAME, EMP2.JOB, EMP2.MGR, EMP2.HIREDATE, EMP2.SAL, EMP2.COMM, EMP2.DEPTNO, EMP2.SLACKER, COUNT(*) AS $f9 FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 GROUP BY EMP2.EMPNO, EMP2.ENAME, EMP2.JOB, EMP2.MGR, EMP2.HIREDATE, EMP2.SAL, EMP2.COMM, EMP2.DEPTNO, EMP2.SLACKER UNION ALL SELECT EMP3.EMPNO, EMP3.ENAME, EMP3.JOB, EMP3.MGR, EMP3.HIREDATE, EMP3.SAL, EMP3.COMM, EMP3.DEPTNO, EMP3.SLACKER, COUNT(*) AS $f9 FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 GROUP BY EMP3.EMPNO, EMP3.ENAME, EMP3.JOB, EMP3.MGR, EMP3.HIREDATE, EMP3.SAL, EMP3.COMM, EMP3.DEPTNO, EMP3.SLACKER) AS t8 GROUP BY t8.EMPNO, t8.ENAME, t8.JOB, t8.MGR, t8.HIREDATE, t8.SAL, t8.COMM, t8.DEPTNO, t8.SLACKER HAVING COUNT(*) = 2 INTERSECT ALL SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE FALSE) AS T RIGHT JOIN DEPT AS DEPT ON T.DEPTNO = DEPT.DEPTNO
SELECT CAST(NULL AS INTEGER) AS EMPNO, CAST(NULL AS VARCHAR(20)) AS ENAME, CAST(NULL AS VARCHAR(10)) AS JOB, CAST(NULL AS INTEGER) AS MGR, CAST(NULL AS TIMESTAMP(0)) AS HIREDATE, CAST(NULL AS INTEGER) AS SAL, CAST(NULL AS INTEGER) AS COMM, CAST(NULL AS INTEGER) AS DEPTNO, CAST(NULL AS BOOLEAN) AS SLACKER, DEPTNO AS DEPTNO0, NAME FROM DEPT
SELECT 1 FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO > 7) AS t LEFT JOIN EMP AS EMP0 ON t.DEPTNO = EMP0.DEPTNO WHERE EMP0.DEPTNO > 9
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 7) AS t2 LEFT JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7) AS t3 ON t2.DEPTNO = t3.DEPTNO WHERE t3.DEPTNO > 9
SELECT t.DEPTNO, t.JOB, MAX(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t6.DEPTNO, t6.JOB, MAX(max1) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, MAX(EMP1.MGR) as max1 FROM EMP AS EMP1 GROUP BY EMP1.DEPTNO, EMP1.JOB UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, MAX(EMP2.MGR) as max1 FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO, EMP2.JOB) AS t6 GROUP BY t6.DEPTNO, t6.JOB
SELECT CASE WHEN NULL IS NULL THEN 2 IS NULL WHEN 2 IS NULL THEN NULL IS NULL ELSE NULL = 2 END FROM (VALUES (0)) AS t
SELECT FALSE FROM (VALUES (0)) AS t2
SELECT EMP.SAL FROM EMP AS EMP, (SELECT * FROM EMP AS EMP0 UNION ALL SELECT * FROM EMP AS EMP1) AS T
SELECT SAL FROM (SELECT * FROM EMP, (SELECT EMPNO AS EMPNO2, ENAME AS ENAME2, JOB AS JOB2, MGR AS MGR2, HIREDATE AS HIREDATE2, SAL AS SAL2, COMM AS COMM2, DEPTNO AS DEPTNO2, SLACKER AS SLACKER2 FROM EMP) AS t UNION ALL SELECT * FROM EMP AS EMP1, (SELECT * FROM EMP) AS t0) AS t1
SELECT 1 FROM DEPT AS DEPT LEFT JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO WHERE DEPT.NAME = 'Charlie' AND EMP.SAL > 100
SELECT 1 FROM (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.NAME = 'Charlie') AS t1 INNER JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.SAL > 100) AS t2 ON t1.DEPTNO = t2.DEPTNO
SELECT t.DEPTNO, t.JOB, AVG(t.EMPNO) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t4.DEPTNO, t4.JOB, AVG(t4.EMPNO) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, EMP1.EMPNO FROM EMP AS EMP1 UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, EMP2.EMPNO FROM EMP AS EMP2) AS t4 GROUP BY t4.DEPTNO, t4.JOB
SELECT EMP.SAL FROM EMP AS EMP WHERE CASE WHEN EMP.SAL = 1000 THEN NULL ELSE 1 END IS NULL OR CASE WHEN EMP.SAL = 2000 THEN NULL ELSE 1 END IS NULL
SELECT EMP0.SAL FROM EMP AS EMP0 WHERE EMP0.SAL = 1000 OR EMP0.SAL = 2000
SELECT DEPT.NAME, MAX(DEPT.NAME), AVG(DEPT.DEPTNO), MIN(DEPT.NAME) FROM DEPT AS DEPT GROUP BY DEPT.NAME
SELECT DEPT0.NAME, MAX(DEPT0.NAME), SUM(DEPT0.DEPTNO) / COUNT(*), MIN(DEPT0.NAME) FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 UNION ALL SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 UNION ALL SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 UNION ALL SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 UNION ALL SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30
SELECT t1.NAME, t1.EMPNO FROM (SELECT t.DEPTNO, t.NAME, t0.EMPNO, t0.ENAME, t0.JOB, t0.MGR, t0.HIREDATE, t0.SAL, t0.COMM, t0.DEPTNO AS DEPTNO1, t0.SLACKER FROM (SELECT DEPT.DEPTNO, DEPT.NAME, DEPT.DEPTNO AS DEPTNO0 FROM DEPT AS DEPT) AS t INNER JOIN (SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER, EMP.DEPTNO AS DEPTNO0 FROM EMP AS EMP) AS t0 ON t.DEPTNO0 = t0.DEPTNO0) AS t1 WHERE t1.JOB = 'Manager'
SELECT t6.NAME, t6.EMPNO FROM (SELECT t4.DEPTNO, t4.NAME, t5.EMPNO, t5.ENAME, t5.JOB, t5.MGR, t5.HIREDATE, t5.SAL, t5.COMM, t5.DEPTNO AS DEPTNO1, t5.SLACKER FROM (SELECT DEPT0.DEPTNO, DEPT0.NAME, DEPT0.DEPTNO AS DEPTNO0 FROM DEPT AS DEPT0) AS t4 INNER JOIN (SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER, EMP0.DEPTNO AS DEPTNO0 FROM EMP AS EMP0) AS t5 ON t4.DEPTNO0 = t5.DEPTNO0) AS t6 WHERE t6.JOB = 'Manager'
SELECT 1 FROM DEPT AS DEPT LEFT JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO WHERE EMP.SAL > 100
SELECT 1 FROM DEPT AS DEPT0 INNER JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.SAL > 100) AS t1 ON DEPT0.DEPTNO = t1.DEPTNO
SELECT SUM(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t
SELECT SUM(t6.sum1) FROM (SELECT SUM(EMP1.MGR) as sum1 FROM EMP AS EMP1 UNION ALL SELECT SUM(EMP2.MGR) as sum2 FROM EMP AS EMP2) AS t6
SELECT * FROM (SELECT * FROM (SELECT * FROM (VALUES (30, 3)) AS t EXCEPT SELECT * FROM (VALUES (20, 2)) AS t0 WHERE t0.EXPR$0 > 30) AS t2 EXCEPT SELECT * FROM (VALUES (40, 4)) AS t3) AS t4 EXCEPT SELECT * FROM (VALUES (50, 5)) AS t5 WHERE t5.EXPR$0 > 50
SELECT * FROM (VALUES (30, 3)) AS t8 EXCEPT SELECT * FROM (VALUES (40, 4)) AS t9
SELECT t.JOB, DEPT.NAME FROM (SELECT * FROM EMP AS EMP WHERE EMP.EMPNO = 10) AS t INNER JOIN DEPT AS DEPT ON t.JOB = DEPT.NAME GROUP BY t.JOB, DEPT.NAME
SELECT * FROM (SELECT EMP0.JOB FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10 GROUP BY EMP0.JOB) AS t2 INNER JOIN (SELECT DEPT0.NAME FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME) AS t3 ON t2.JOB = t3.NAME
SELECT t0.JOB, t1.NAME FROM (SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER, EMP.DEPTNO + EMP.EMPNO AS $f9 FROM EMP AS EMP WHERE EMP.EMPNO = 10) AS t0 INNER JOIN (SELECT DEPT.DEPTNO, DEPT.NAME, DEPT.DEPTNO + 5 AS $f2 FROM DEPT AS DEPT) AS t1 ON t0.JOB = t1.NAME AND t0.$f9 = t1.$f2 GROUP BY t0.JOB, t1.NAME
SELECT t5.JOB, t7.NAME FROM (SELECT EMP0.JOB, EMP0.DEPTNO + EMP0.EMPNO AS $f9 FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10 GROUP BY EMP0.JOB, EMP0.DEPTNO + EMP0.EMPNO) AS t5 INNER JOIN (SELECT DEPT0.NAME, DEPT0.DEPTNO + 5 AS $f2 FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME, DEPT0.DEPTNO + 5) AS t7 ON t5.JOB = t7.NAME AND t5.$f9 = t7.$f2 GROUP BY t5.JOB, t7.NAME
SELECT t.EMPNO, DEPT.DEPTNO AS DEPTNO0 FROM (SELECT * FROM EMP AS EMP WHERE EMP.EMPNO = 10) AS t INNER JOIN DEPT AS DEPT ON t.EMPNO = DEPT.DEPTNO GROUP BY t.EMPNO, DEPT.DEPTNO
SELECT t1.EMPNO, DEPT0.DEPTNO AS DEPTNO0 FROM (SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10) AS t1 INNER JOIN DEPT AS DEPT0 ON t1.EMPNO = DEPT0.DEPTNO GROUP BY t1.EMPNO, DEPT0.DEPTNO
SELECT EMP.DEPTNO FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO GROUP BY EMP.DEPTNO
SELECT t0.DEPTNO FROM (SELECT EMP0.DEPTNO FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO) AS t0 INNER JOIN DEPT AS DEPT0 ON t0.DEPTNO = DEPT0.DEPTNO
SELECT EMP.DEPTNO, DEPT.DEPTNO AS DEPTNO0 FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO GROUP BY EMP.DEPTNO, DEPT.DEPTNO
SELECT t0.DEPTNO, DEPT0.DEPTNO AS DEPTNO0 FROM (SELECT EMP0.DEPTNO FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO) AS t0 INNER JOIN DEPT AS DEPT0 ON t0.DEPTNO = DEPT0.DEPTNO
SELECT 1+2, D.DEPTNO+(3+4), (5+6)+D.DEPTNO, CAST(NULL AS INTEGER), COALESCE(2,NULL), ROW(7+8) FROM DEPT D INNER JOIN EMP E ON D.DEPTNO = E.DEPTNO + (5-5) WHERE D.DEPTNO=(7+8) AND D.DEPTNO=(8+7) AND D.DEPTNO=COALESCE(2,NULL)
SELECT 3, 22, 26, CAST(NULL AS INTEGER), CAST(2 AS INTEGER), ROW(15) FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(DEPTNO, NAME, EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO0, SLACKER) WHERE 1 = 0
SELECT t1.ENAME, SUM(t1.U) FROM (SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER, NULL AS U FROM EMP AS EMP UNION ALL SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER, NULL AS U FROM EMP AS EMP0) AS t1 GROUP BY t1.ENAME
SELECT t8.ENAME, SUM(t8.sum1) FROM (SELECT EMP1.ENAME, SUM(NULL) as sum1 FROM EMP AS EMP1 GROUP BY EMP1.ENAME UNION ALL SELECT EMP2.ENAME, SUM(NULL) FROM EMP AS EMP2 GROUP BY EMP2.ENAME) AS t8 GROUP BY t8.ENAME
SELECT t.ENAME FROM (SELECT DEPT.DEPTNO, EMP.ENAME FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO AND DEPT.DEPTNO = 10) AS t WHERE t.DEPTNO = 10
SELECT EMP0.ENAME FROM EMP AS EMP0 INNER JOIN (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.DEPTNO = 10) AS t1 ON EMP0.DEPTNO = t1.DEPTNO
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 UNION SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 UNION SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 UNION SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 UNION SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30
SELECT * FROM DEPT AS DEPT LEFT JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO WHERE EMP.DEPTNO IS NOT NULL AND EMP.SAL > 100
SELECT DEPT0.DEPTNO, DEPT0.NAME, t0.EMPNO AS EMPNO, t0.ENAME AS ENAME, t0.JOB AS JOB, t0.MGR, t0.HIREDATE AS HIREDATE, t0.SAL AS SAL, t0.COMM AS COMM, t0.DEPTNO AS DEPTNO0, t0.SLACKER AS SLACKER FROM DEPT AS DEPT0 INNER JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.SAL > 100) AS t0 ON DEPT0.DEPTNO = t0.DEPTNO
SELECT T.JOB, SUM(T.SAL) FROM (SELECT * FROM EMP AS EMP WHERE EMP.EMPNO = 10) AS T INNER JOIN DEPT AS DEPT ON T.JOB = DEPT.NAME GROUP BY T.JOB, DEPT.NAME
SELECT t1.JOB, CAST(t1.SAL * t2.$f1 AS INTEGER) FROM (SELECT JOB, SAL FROM EMP WHERE EMPNO = 10) AS t1 INNER JOIN (SELECT NAME, COUNT(*) AS $f1 FROM DEPT GROUP BY NAME) AS t2 ON t1.JOB = t2.NAME
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EMP.DEPTNO IN (SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) OR EMP.SAL < 100
SELECT EMP.EMPNO FROM EMP LEFT JOIN (SELECT DEPTNO, TRUE AS i FROM EMP WHERE EMPNO < 20 GROUP BY DEPTNO, TRUE) AS t1 ON EMP.DEPTNO = t1.DEPTNO WHERE t1.i IS NOT NULL OR EMP.SAL < 100
SELECT COUNT(*) FROM EMP AS EMP WHERE CASE WHEN EMP.DEPTNO = 20 THEN 2 WHEN EMP.DEPTNO = 10 THEN 1 ELSE 3 END = 1
SELECT COUNT(*) FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 10
SELECT 1 FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 7 OR EMP.DEPTNO = 9 OR EMP.COMM > 10) AS t INNER JOIN EMP AS EMP0 ON t.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 7 OR EMP1.DEPTNO = 9 OR EMP1.COMM > 10) AS t1 INNER JOIN EMP AS EMP2 ON t1.DEPTNO = EMP2.DEPTNO
SELECT U.Z + U.X FROM ( SELECT R.X + R.Y AS Z, R.X FROM ( SELECT * FROM (VALUES (10, 1), (30, 3)) AS T(X, Y) WHERE X + Y > 50) AS R ) AS U
SELECT * FROM (VALUES (NULL)) AS t(EXPR$0) WHERE 1 = 0
SELECT 1 FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 7 OR EMP.DEPTNO = 9 OR EMP.DEPTNO > 10) AS t INNER JOIN EMP AS EMP0 ON t.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 7 OR EMP1.DEPTNO = 9 OR EMP1.DEPTNO > 10) AS t1 INNER JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 7 OR EMP2.DEPTNO = 9 OR EMP2.DEPTNO > 10) AS t2 ON t1.DEPTNO = t2.DEPTNO
SELECT EMP.DEPTNO, MAX(EMP.ENAME) FROM EMP AS EMP GROUP BY EMP.DEPTNO, 4
SELECT EMP0.DEPTNO, MAX(EMP0.ENAME) FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO
SELECT * FROM DEPT AS DEPT UNION SELECT * FROM DEPT AS DEPT0
SELECT t0.DEPTNO, t0.NAME FROM (SELECT * FROM DEPT AS DEPT1 UNION ALL SELECT * FROM DEPT AS DEPT2) AS t0 GROUP BY t0.DEPTNO, t0.NAME
SELECT EMP.ENAME FROM EMP AS EMP, DEPT AS DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO AND EMP.ENAME = 'foo'
SELECT t1.ENAME FROM (SELECT EMP0.DEPTNO,EMP0.ENAME FROM EMP AS EMP0 INNER JOIN DEPT AS DEPT0 ON EMP0.DEPTNO = DEPT0.DEPTNO WHERE EMP0.ENAME = 'foo') AS t1 INNER JOIN DEPT AS DEPT1 ON t1.DEPTNO = DEPT1.DEPTNO
SELECT t3.DEPTNO, t3.JOB FROM (SELECT EMP.DEPTNO, EMP.JOB FROM EMP AS EMP GROUP BY EMP.DEPTNO, EMP.JOB UNION ALL SELECT EMP0.DEPTNO, EMP0.JOB FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO, EMP0.JOB) AS t3 GROUP BY t3.DEPTNO, t3.JOB
SELECT t7.DEPTNO, t7.JOB FROM (SELECT EMP1.DEPTNO, EMP1.JOB FROM EMP AS EMP1 UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB FROM EMP AS EMP2) AS t7 GROUP BY t7.DEPTNO, t7.JOB
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10) AS t WHERE t.DEPTNO + 5 > t.EMPNO
SELECT * FROM (SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 10) AS t1 WHERE 15 > t1.EMPNO
SELECT t.ENAME, SUM(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.ENAME
SELECT t6.ENAME, SUM(sum1) FROM (SELECT EMP1.ENAME, SUM(EMP1.MGR) as sum1 FROM EMP AS EMP1 GROUP BY EMP1.ENAME UNION ALL SELECT EMP2.ENAME, SUM(EMP2.MGR) FROM EMP AS EMP2 GROUP BY EMP2.ENAME) AS t6 GROUP BY t6.ENAME
SELECT SUM(EMPNO) FROM EMP WHERE FALSE GROUP BY DEPTNO
SELECT * FROM (VALUES (NULL)) AS t(EXPR$0) WHERE 1 = 0
SELECT 1 FROM (SELECT EMP.COMM AS DEPTNO FROM EMP AS EMP WHERE EMP.COMM > 7) AS t0 INNER JOIN EMP AS EMP0 ON t0.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM (SELECT EMP1.COMM AS DEPTNO FROM EMP AS EMP1 WHERE EMP1.COMM > 7) AS t3 INNER JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7) AS t4 ON t3.DEPTNO = t4.DEPTNO
SELECT 1 FROM (SELECT EMP.DEPTNO, COUNT(*) FROM EMP AS EMP WHERE EMP.DEPTNO > 7 GROUP BY EMP.DEPTNO) AS t1 INNER JOIN EMP AS EMP0 ON t1.DEPTNO = EMP0.DEPTNO
SELECT 1 FROM (SELECT EMP1.DEPTNO, COUNT(*) FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 7 GROUP BY EMP1.DEPTNO) AS t5 INNER JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7) AS t6 ON t5.DEPTNO = t6.DEPTNO
SELECT * FROM EMP AS EMP ORDER BY EMP.DEPTNO FETCH NEXT 0 ROWS ONLY
SELECT * FROM (VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) AS t(EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER) WHERE 1 = 0
SELECT t0.NAME, SUM(DISTINCT t0.CN), SUM(DISTINCT t0.SM) FROM (SELECT DEPT.NAME, COUNT(*) AS CN, SUM(DEPT.DEPTNO) AS SM FROM DEPT AS DEPT GROUP BY DEPT.NAME) AS t0 GROUP BY t0.NAME
SELECT t3.NAME, SUM(t3.CN), SUM(t3.SM) FROM (SELECT DEPT0.NAME, COUNT(*) AS CN, SUM(DEPT0.DEPTNO) AS SM FROM DEPT AS DEPT0 GROUP BY DEPT0.NAME) AS t3 GROUP BY t3.NAME
SELECT EMP.DEPTNO, COUNT(DISTINCT EMP.ENAME) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, COUNT(ENAME) FROM (SELECT ENAME, DEPTNO FROM EMP GROUP BY ENAME, DEPTNO) AS t GROUP BY DEPTNO
SELECT EMP.DEPTNO, COUNT(DISTINCT EMP.ENAME), SUM(EMP.SAL) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, COUNT(ENAME) FILTER (WHERE $g_0), CAST(MIN(EXPR$2) FILTER (WHERE $g_1) AS INTEGER) FROM (SELECT DEPTNO, ENAME, SUM(SAL) AS EXPR$2, GROUPING(DEPTNO, ENAME) = 0 AS $g_0, GROUPING(DEPTNO, ENAME) = 1 AS $g_1 FROM EMP GROUP BY GROUPING SETS((ENAME, DEPTNO), DEPTNO)) AS t1 GROUP BY DEPTNO
SELECT COUNT(DISTINCT EMP.DEPTNO), SUM(EMP.SAL) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT COUNT(DEPTNO) FILTER (WHERE $g_0), CAST(MIN(EXPR$1) FILTER (WHERE $g_0) AS INTEGER) FROM (SELECT DEPTNO, SUM(SAL) AS EXPR$1, GROUPING(DEPTNO) = 0 AS $g_0 FROM EMP GROUP BY DEPTNO) AS t1 GROUP BY DEPTNO
SELECT EMP.EMPNO, EMP.DEPTNO IN (SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) AS D FROM EMP AS EMP
SELECT EMP1.EMPNO, CASE WHEN t5.i IS NOT NULL THEN TRUE ELSE FALSE END AS D FROM EMP AS EMP1 LEFT JOIN (SELECT EMP2.DEPTNO, 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20 GROUP BY EMP2.DEPTNO, TRUE) AS t5 ON EMP1.DEPTNO = t5.DEPTNO
SELECT EMP.DEPTNO, EMP.ENAME, CASE WHEN 1 = 2 THEN SUBSTRING(EMP.ENAME FROM 1 FOR 2) ELSE NULL END FROM EMP AS EMP GROUP BY EMP.DEPTNO, EMP.ENAME, CASE WHEN 1 = 2 THEN SUBSTRING(EMP.ENAME FROM 1 FOR 2) ELSE NULL END
SELECT EMP0.DEPTNO, EMP0.ENAME, NULL FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO, EMP0.ENAME, NULL
SELECT t.DEPTNO, t.JOB, COUNT(*) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t6.DEPTNO, t6.JOB, SUM(count1) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, COUNT(*) as count1 FROM EMP AS EMP1 GROUP BY EMP1.DEPTNO, EMP1.JOB UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, COUNT(*) as count1 FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO, EMP2.JOB) AS t6 GROUP BY t6.DEPTNO, t6.JOB
SELECT EMP.EMPNO, COUNT(*), AVG(DISTINCT DEPT.DEPTNO) FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO GROUP BY EMP.EMPNO
SELECT t0.EMPNO, COALESCE(SUM(t0.EXPR$1), 0), AVG(t0.DEPTNO0) FROM (SELECT EMP.EMPNO, DEPT.DEPTNO AS DEPTNO0, COUNT(*) AS EXPR$1 FROM EMP INNER JOIN DEPT ON EMP.DEPTNO = DEPT.DEPTNO GROUP BY EMP.EMPNO, DEPT.DEPTNO) AS t0 GROUP BY t0.EMPNO
SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 UNION SELECT * FROM (SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20 INTERSECT SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30) AS t2
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 UNION SELECT * FROM (SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 INTERSECT SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30) AS t7
SELECT EMP.DEPTNO, SUM(EMP.DEPTNO), SUM(DISTINCT EMP.SAL), MAX(EMP.DEPTNO), MAX(EMP.COMM) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, SUM(EXPR$1), SUM(SAL), MAX(EXPR$3), MAX(EXPR$4) FROM (SELECT DEPTNO, SAL, SUM(DEPTNO) AS EXPR$1, MAX(DEPTNO) AS EXPR$3, MAX(COMM) AS EXPR$4 FROM EMP GROUP BY DEPTNO, SAL) AS t0 GROUP BY DEPTNO
SELECT EMP.DEPTNO, COUNT(*), SUM(DISTINCT EMP.SAL) FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, COALESCE(SUM(EXPR$1), 0), SUM(SAL) FROM (SELECT DEPTNO, SAL, COUNT(*) AS EXPR$1 FROM EMP GROUP BY DEPTNO, SAL) AS t0 GROUP BY DEPTNO
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EMP.EMPNO = 10 AND EMP.EMPNO IS NOT NULL
SELECT EMP0.EMPNO FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10
SELECT t.DEPTNO, t.JOB, MIN(t.EMPNO) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.DEPTNO, t.JOB
SELECT t6.DEPTNO, t6.JOB, MIN(t6.min1) FROM (SELECT EMP1.DEPTNO, EMP1.JOB, MIN(EMP1.EMPNO) as min1 FROM EMP AS EMP1 GROUP BY EMP1.DEPTNO, EMP1.JOB UNION ALL SELECT EMP2.DEPTNO, EMP2.JOB, MIN(EMP2.EMPNO) as min1 FROM EMP AS EMP2 GROUP BY EMP2.DEPTNO, EMP2.JOB) AS t6 GROUP BY t6.DEPTNO, t6.JOB
SELECT 4, 2 + 3, MAX(EMP.MGR) FROM EMP AS EMP GROUP BY 4, 2 + 3
SELECT 4, 2 + 3, MAX(EMP0.MGR) FROM EMP AS EMP0 GROUP BY 4
SELECT EMP.DEPTNO, MAX(EMP.MGR) FROM EMP AS EMP GROUP BY EMP.DEPTNO, 4, 2 + 3, EMP.DEPTNO + 42
SELECT EMP0.DEPTNO, MAX(EMP0.MGR) FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO, EMP0.DEPTNO + 42
SELECT * FROM (VALUES (30, 3)) INTERSECT SELECT * FROM (VALUES (10, 1), (30, 3)) AS T (X, Y) WHERE X > 50 INTERSECT SELECT * FROM (VALUES (30, 3))
SELECT * FROM (SELECT NULL AS EXPR$0, NULL AS EXPR$1) AS t WHERE 1 = 0
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END FROM BONUS AS BONUS RIGHT JOIN EMP AS EMP ON BONUS.ENAME = EMP.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END
SELECT COUNT(*), t3.expr1 FROM (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t2 RIGHT JOIN (SELECT EMP0.ENAME, CASE WHEN EMP0.SAL < 11 THEN 11 ELSE -1 * EMP0.SAL END AS expr1 FROM EMP AS EMP0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY t3.expr1
SELECT EMP.DEPTNO, EMP.DEPTNO + 1, EMP.EMPNO + EMP.DEPTNO FROM EMP AS EMP WHERE EMP.DEPTNO = 10
SELECT 10 AS DEPTNO, 11, EMP0.EMPNO + 10 FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 10
SELECT * FROM (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.DEPTNO < 4) AS t0 INNER JOIN (SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.DEPTNO > 7 UNION ALL SELECT EMP1.DEPTNO FROM EMP AS EMP1) AS t4 ON t0.DEPTNO = t4.DEPTNO
SELECT * FROM (SELECT EMP2.DEPTNO FROM EMP AS EMP2 WHERE EMP2.DEPTNO < 4) AS t6 INNER JOIN (SELECT * FROM (SELECT EMP3.DEPTNO FROM EMP AS EMP3 WHERE EMP3.DEPTNO > 7 UNION ALL SELECT EMP4.DEPTNO FROM EMP AS EMP4) AS t10 WHERE t10.DEPTNO < 4) AS t11 ON t6.DEPTNO = t11.DEPTNO
SELECT * FROM EMP AS EMP WHERE (EMP.EMPNO, EMP.DEPTNO) IN (SELECT EMP0.EMPNO, EMP0.DEPTNO FROM EMP AS EMP0 GROUP BY EMP0.EMPNO, EMP0.DEPTNO) OR EMP.DEPTNO < 40 + 60
SELECT * FROM EMP AS EMP1 WHERE (EMP1.EMPNO, EMP1.DEPTNO) IN (SELECT EMP2.EMPNO, EMP2.DEPTNO FROM EMP AS EMP2 GROUP BY EMP2.EMPNO, EMP2.DEPTNO) OR EMP1.DEPTNO < 100
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 INTERSECT SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 INTERSECT SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 INTERSECT SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 INTERSECT SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30
SELECT T1.ENAME, SUM(T1.U) FROM (SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER, 2 AS U FROM EMP AS EMP UNION ALL SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER, 3 AS U FROM EMP AS EMP0) AS T1 GROUP BY T1.ENAME
SELECT ENAME, SUM(EXPR$1) FROM (SELECT ENAME, SUM(2) AS EXPR$1 FROM EMP GROUP BY ENAME UNION ALL SELECT ENAME, SUM(3) AS EXPR$1 FROM EMP GROUP BY ENAME) AS t3 GROUP BY ENAME
SELECT 1 FROM EMP AS EMP INNER JOIN DEPT AS DEPT ON EMP.DEPTNO = DEPT.DEPTNO
SELECT 1 FROM EMP AS EMP0 INNER JOIN DEPT AS DEPT0 ON EMP0.DEPTNO = DEPT0.DEPTNO INNER JOIN DEPT AS DEPT1 ON EMP0.DEPTNO = DEPT1.DEPTNO
SELECT EMP.EMPNO, EXISTS (SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) AS D FROM EMP AS EMP
SELECT EMP1.EMPNO, CASE WHEN t3.i IS NOT NULL THEN TRUE ELSE FALSE END AS D FROM EMP AS EMP1 LEFT JOIN (SELECT 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20 GROUP BY TRUE) AS t3 ON TRUE
SELECT EMP.ENAME FROM EMP AS EMP, DEPT AS DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO AND EMP.ENAME = 'foo'
SELECT t1.ENAME FROM (SELECT * FROM EMP AS EMP0 WHERE EMP0.ENAME = 'foo') AS t1 INNER JOIN DEPT AS DEPT0 ON t1.DEPTNO = DEPT0.DEPTNO
SELECT 1 FROM DEPT AS DEPT RIGHT JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO WHERE DEPT.NAME = 'Charlie'
SELECT 1 FROM (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.NAME = 'Charlie') AS t1 INNER JOIN EMP AS EMP0 ON t1.DEPTNO = EMP0.DEPTNO
SELECT EMP.DEPTNO, COUNT(DISTINCT EMP.DEPTNO, EMP.JOB) AS CDDJ, SUM(EMP.SAL) AS S FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, COUNT(DEPTNO, JOB) FILTER (WHERE $g_0) AS CDDJ, CAST(MIN(S) FILTER (WHERE $g_1) AS INTEGER) AS S FROM (SELECT DEPTNO, JOB, SUM(SAL) AS S, GROUPING(DEPTNO, JOB) = 0 AS $g_0, GROUPING(DEPTNO, JOB) = 1 AS $g_1 FROM EMP GROUP BY GROUPING SETS((DEPTNO, JOB), DEPTNO)) AS t1 GROUP BY DEPTNO
SELECT DEPT.DEPTNO, EMP.DEPTNO AS DEPTNO0 FROM DEPT AS DEPT, EMP AS EMP WHERE DEPT.DEPTNO + 10 = EMP.DEPTNO * 2
SELECT t1.DEPTNO, t2.DEPTNO AS DEPTNO0 FROM (SELECT DEPT0.DEPTNO, DEPT0.NAME, DEPT0.DEPTNO + 10 AS $f2 FROM DEPT AS DEPT0) AS t1 INNER JOIN (SELECT EMP0.EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER, EMP0.DEPTNO * 2 AS $f9 FROM EMP AS EMP0) AS t2 ON t1.$f2 = t2.$f9
SELECT EMP.ENAME FROM EMP AS EMP, EMP AS EMP0, DEPT AS DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO AND EMP.DEPTNO = EMP0.DEPTNO AND DEPT.NAME = 'foo'
SELECT EMP1.ENAME FROM EMP AS EMP1 INNER JOIN (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.NAME = 'foo') AS t1 ON EMP1.DEPTNO = t1.DEPTNO INNER JOIN EMP AS EMP2 ON t1.DEPTNO = EMP2.DEPTNO
SELECT 1 FROM DEPT AS DEPT FULL JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO WHERE DEPT.NAME = 'Charlie'
SELECT 1 FROM (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.NAME = 'Charlie') AS t1 LEFT JOIN EMP AS EMP0 ON t1.DEPTNO = EMP0.DEPTNO
SELECT EMP.DEPTNO, MAX(EMP.MGR) FROM EMP AS EMP GROUP BY 4, EMP.DEPTNO
SELECT EMP0.DEPTNO, MAX(EMP0.MGR) FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO
SELECT 1 FROM (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.DEPTNO > 7 UNION ALL SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.DEPTNO > 10) AS t3 INNER JOIN EMP AS EMP1 ON t3.DEPTNO = EMP1.DEPTNO
SELECT 1 FROM (SELECT EMP2.DEPTNO FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 7 UNION ALL SELECT EMP3.DEPTNO FROM EMP AS EMP3 WHERE EMP3.DEPTNO > 10) AS t9 INNER JOIN (SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO > 7 OR EMP4.DEPTNO > 10) AS t10 ON t9.DEPTNO = t10.DEPTNO
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.EMPNO = 10) AS t LEFT JOIN DEPT AS DEPT ON t.EMPNO = DEPT.DEPTNO
SELECT * FROM (SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10) AS t0 LEFT JOIN (SELECT * FROM DEPT AS DEPT0 WHERE DEPT0.DEPTNO = 10) AS t1 ON TRUE
SELECT COUNT(*) FROM EMP AS EMP WHERE CASE WHEN EMP.DEPTNO = 20 THEN 2 WHEN EMP.DEPTNO = 10 THEN 1 ELSE NULL END = 1
SELECT COUNT(*) FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 10
SELECT COUNT(*) FROM EMP AS EMP WHERE CASE WHEN EMP.DEPTNO = 30 THEN 1 WHEN EMP.DEPTNO = 20 THEN 2 WHEN EMP.DEPTNO = 10 THEN 1 WHEN EMP.DEPTNO = 30 THEN 111 ELSE 0 END = 1
SELECT COUNT(*) FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 30 OR EMP0.DEPTNO = 10
SELECT EMP.EMPNO FROM EMP AS EMP LEFT JOIN DEPT AS DEPT ON (((SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20))) < (((SELECT EMP1.DEPTNO FROM EMP AS EMP1 WHERE EMP1.EMPNO > 100)))
SELECT EMP2.EMPNO FROM EMP AS EMP2 LEFT JOIN (DEPT AS DEPT0 LEFT JOIN (SELECT SINGLE_VALUE(EMP3.DEPTNO) AS $f0 FROM EMP AS EMP3 WHERE EMP3.EMPNO < 20) AS t6 ON TRUE LEFT JOIN (SELECT SINGLE_VALUE(EMP4.DEPTNO) AS $f0 FROM EMP AS EMP4 WHERE EMP4.EMPNO > 100) AS t9 ON TRUE) ON t6.$f0 < t9.$f0
SELECT 4, 2 + 3, MAX(5) FROM EMP AS EMP GROUP BY 4, 2 + 3
SELECT 4, 2 + 3, MAX(5) FROM EMP AS EMP0 GROUP BY 4
SELECT 1 FROM DEPT AS DEPT LEFT JOIN EMP AS EMP ON DEPT.DEPTNO = EMP.DEPTNO
SELECT 1 FROM EMP AS EMP0 RIGHT JOIN DEPT AS DEPT0 ON EMP0.DEPTNO = DEPT0.DEPTNO
SELECT T.SAL FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS T, EMP AS EMP1
SELECT SAL2 AS SAL FROM (SELECT * FROM (SELECT EMPNO AS EMPNO2, ENAME AS ENAME2, JOB AS JOB2, MGR AS MGR2, HIREDATE AS HIREDATE2, SAL AS SAL2, COMM AS COMM2, DEPTNO AS DEPTNO2, SLACKER AS SLACKER2 FROM EMP) AS t, EMP AS EMP0 UNION ALL SELECT * FROM (SELECT * FROM EMP) AS t0, EMP AS EMP2) AS t1
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 UNION ALL SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 UNION SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 UNION SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20 UNION SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30
SELECT EMP.DEPTNO FROM EMP AS EMP GROUP BY EMP.DEPTNO HAVING COUNT(*) > 1
SELECT EMP0.DEPTNO FROM EMP AS EMP0 GROUP BY EMP0.DEPTNO HAVING COUNT(*) > 1
SELECT * FROM (VALUES (1,2)) WHERE 1 + 2 > 3 + CAST(NULL AS INTEGER)
SELECT * FROM (SELECT NULL AS EXPR$0, NULL AS EXPR$1) AS t WHERE 1 = 0
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EXISTS (SELECT * FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) OR EMP.SAL < 100
SELECT EMP1.EMPNO FROM EMP AS EMP1 LEFT JOIN (SELECT 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20 GROUP BY TRUE) AS t4 ON TRUE WHERE t4.i IS NOT NULL OR EMP1.SAL < 100
SELECT EMP.JOB, EMP.EMPNO, EMP.SAL, SUM(EMP.SAL) AS S FROM EMP AS EMP WHERE EMP.EMPNO = 10 GROUP BY EMP.JOB, EMP.EMPNO, EMP.SAL
SELECT EMP0.JOB, 10 AS EMPNO, EMP0.SAL, SUM(EMP0.SAL) AS S FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10 GROUP BY EMP0.JOB, EMP0.SAL
SELECT EMP.MGR FROM EMP AS EMP WHERE CASE WHEN EMP.MGR < 10 THEN TRUE ELSE FALSE END
SELECT * FROM (SELECT EMP0.MGR FROM EMP AS EMP0) AS t2 WHERE t2.MGR < 10
SELECT t0.SAL FROM (SELECT * FROM (SELECT EMP.SAL, EMP.DEPTNO FROM EMP AS EMP) AS t WHERE t.DEPTNO = 200) AS t0 INNER JOIN (SELECT t1.DEPTNO FROM (SELECT EMP0.SAL, EMP0.DEPTNO FROM EMP AS EMP0) AS t1 WHERE t1.SAL = 100) AS t3 ON t0.DEPTNO = t3.DEPTNO
SELECT t6.SAL FROM (SELECT * FROM (SELECT EMP1.SAL, EMP1.DEPTNO FROM EMP AS EMP1) AS t5 WHERE t5.DEPTNO = 200) AS t6 INNER JOIN (SELECT t7.DEPTNO FROM (SELECT EMP2.SAL, EMP2.DEPTNO FROM EMP AS EMP2) AS t7 WHERE t7.SAL = 100) AS t9 ON t6.DEPTNO = t9.DEPTNO
SELECT EMP.EMPNO, (((SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20))) AS D FROM EMP AS EMP
SELECT EMP1.EMPNO, t4.$f0 AS D FROM EMP AS EMP1 LEFT JOIN (SELECT SINGLE_VALUE(EMP2.DEPTNO) AS $f0 FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20) AS t4 ON TRUE
SELECT COUNT(DISTINCT EMP.ENAME), COUNT(DISTINCT EMP.JOB) FROM EMP AS EMP
SELECT COUNT(ENAME) FILTER (WHERE $g_1), COUNT(JOB) FILTER (WHERE $g_2) FROM (SELECT ENAME, JOB, GROUPING(ENAME, JOB) = 1 AS $g_1, GROUPING(ENAME, JOB) = 2 AS $g_2 FROM EMP GROUP BY GROUPING SETS(ENAME, JOB)) AS t0
WITH E2 AS ( SELECT EMPNO, CASE WHEN TRUE THEN DEPTNO ELSE NULL END AS DEPTNO FROM EMP) SELECT EMPNO, DEPTNO IN (SELECT DEPTNO FROM E2 WHERE EMPNO < 20) AS D FROM E2
SELECT EMP.EMPNO, CASE WHEN t2.c = 0 THEN FALSE WHEN CASE WHEN TRUE THEN CAST(EMP.DEPTNO AS INTEGER) ELSE NULL END IS NULL THEN NULL WHEN t6.i IS NOT NULL THEN TRUE WHEN t2.ck < t2.c THEN NULL ELSE FALSE END AS D FROM EMP CROSS JOIN (SELECT COUNT(*) AS c, COUNT(DEPTNO) AS ck FROM (SELECT EMPNO, CASE WHEN TRUE THEN CAST(DEPTNO AS INTEGER) ELSE NULL END AS DEPTNO FROM EMP) AS t WHERE EMPNO < 20) AS t2 LEFT JOIN (SELECT DEPTNO, TRUE AS i FROM (SELECT EMPNO, CASE WHEN TRUE THEN CAST(DEPTNO AS INTEGER) ELSE NULL END AS DEPTNO FROM EMP) AS t3 WHERE EMPNO < 20 GROUP BY DEPTNO, TRUE) AS t6 ON CASE WHEN TRUE THEN CAST(EMP.DEPTNO AS INTEGER) ELSE NULL END = t6.DEPTNO
SELECT t0.ENAME, t0.SAL, t0.DEPTNO FROM (SELECT EMP.ENAME, EMP.SAL, EMP.DEPTNO FROM EMP AS EMP) AS t0 WHERE t0.SAL > 5000 GROUP BY t0.ENAME, t0.SAL, t0.DEPTNO
SELECT EMP0.ENAME, EMP0.SAL, EMP0.DEPTNO FROM EMP AS EMP0 GROUP BY EMP0.ENAME, EMP0.SAL, EMP0.DEPTNO HAVING EMP0.SAL > 5000
SELECT COUNT(*) AS C FROM EMP AS EMP WHERE EMP.DEPTNO = 10 GROUP BY EMP.DEPTNO
SELECT COUNT(*) AS C FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 10 GROUP BY EMP0.DEPTNO
SELECT EMP.JOB FROM EMP AS EMP WHERE EMP.SAL IS NULL AND EMP.JOB = 'Clerk' GROUP BY EMP.SAL, EMP.JOB HAVING COUNT(*) > 3
SELECT t7.JOB FROM (SELECT EMP0.SAL, 'Clerk' AS JOB, COUNT(*) AS $f2 FROM EMP AS EMP0 WHERE EMP0.SAL IS NULL AND EMP0.JOB = 'Clerk' GROUP BY EMP0.SAL) AS t7 WHERE t7.$f2 > 3
SELECT t0.EMPNO, t0.ENAME, t0.JOB, t0.MGR, t0.HIREDATE, t0.SAL, t0.COMM, t0.DEPTNO, t0.SLACKER, t1.DEPTNO AS DEPTNO0, t1.NAME FROM (SELECT EMP.EMPNO, EMP.ENAME, EMP.JOB, EMP.MGR, EMP.HIREDATE, EMP.SAL, EMP.COMM, EMP.DEPTNO, EMP.SLACKER, EMP.DEPTNO + EMP.EMPNO AS $f9 FROM EMP AS EMP WHERE EMP.EMPNO = 10) AS t0 INNER JOIN (SELECT DEPT.DEPTNO, DEPT.NAME, DEPT.DEPTNO + 5 AS $f2 FROM DEPT AS DEPT) AS t1 ON t0.EMPNO = t1.DEPTNO AND t0.$f9 = t1.$f2
SELECT 10 AS EMPNO, t5.ENAME, t5.JOB, t5.MGR, t5.HIREDATE, t5.SAL, t5.COMM, t5.DEPTNO, t5.SLACKER, 10 AS DEPTNO0, t7.NAME FROM (SELECT 10 AS EMPNO, EMP0.ENAME, EMP0.JOB, EMP0.MGR, EMP0.HIREDATE, EMP0.SAL, EMP0.COMM, EMP0.DEPTNO, EMP0.SLACKER, EMP0.DEPTNO + 10 AS $f9 FROM EMP AS EMP0 WHERE EMP0.EMPNO = 10) AS t5 INNER JOIN (SELECT 10 AS DEPTNO, DEPT0.NAME, 15 AS $f2 FROM DEPT AS DEPT0 WHERE DEPT0.DEPTNO = 10) AS t7 ON t5.$f9 = 15
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END FROM EMP AS EMP INNER JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN -1 * EMP.SAL ELSE EMP.SAL END
SELECT COUNT(*), t.EXPR$1 FROM (SELECT ENAME, CASE WHEN SAL < 11 THEN -1 * SAL ELSE SAL END AS EXPR$1 FROM EMP) AS t INNER JOIN (SELECT ENAME FROM BONUS) AS t0 ON t.ENAME = t0.ENAME GROUP BY t.EXPR$1
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END FROM BONUS AS BONUS LEFT JOIN EMP AS EMP ON BONUS.ENAME = EMP.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END
SELECT COUNT(*), CASE WHEN t3.expr1 THEN 11 ELSE t3.expr2 END FROM (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t2 LEFT JOIN (SELECT EMP0.ENAME, EMP0.SAL < 11 AS expr1, -1 * EMP0.SAL AS expr2 FROM EMP AS EMP0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY CASE WHEN t3.expr1 THEN 11 ELSE t3.expr2 END
SELECT DEPT.DEPTNO, DEPT.NAME FROM DEPT AS DEPT FULL JOIN (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.SAL > 100 GROUP BY EMP.DEPTNO) AS t1 ON DEPT.DEPTNO = t1.DEPTNO
SELECT DEPT0.DEPTNO, DEPT0.NAME FROM DEPT AS DEPT0 FULL JOIN (SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.SAL > 100 GROUP BY EMP0.DEPTNO) AS t5 ON DEPT0.DEPTNO = t5.DEPTNO
SELECT DEPT.NAME FROM DEPT AS DEPT LEFT JOIN (SELECT EMP.DEPTNO FROM EMP AS EMP WHERE EMP.SAL > 100 GROUP BY EMP.DEPTNO) AS t1 ON DEPT.DEPTNO = t1.DEPTNO
SELECT DEPT0.NAME FROM DEPT AS DEPT0
SELECT EMP.EMPNO, (EMP.EMPNO, EMP.DEPTNO) IN (SELECT EMP0.EMPNO, EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) AS D FROM EMP AS EMP
SELECT EMP1.EMPNO, CASE WHEN t4.i IS NOT NULL THEN TRUE ELSE FALSE END AS D FROM EMP AS EMP1 LEFT JOIN (SELECT EMP2.EMPNO, EMP2.DEPTNO, 1 AS i FROM EMP AS EMP2 WHERE EMP2.EMPNO < 20) AS t4 ON EMP1.EMPNO = t4.EMPNO AND EMP1.DEPTNO = t4.DEPTNO
SELECT * FROM ( SELECT * FROM EMP WHERE FALSE) E LEFT JOIN DEPT D ON E.DEPTNO = D.DEPTNO
SELECT * FROM (SELECT NULL AS EMPNO, NULL AS ENAME, NULL AS JOB, NULL AS MGR, NULL AS HIREDATE, NULL AS SAL, NULL AS COMM, NULL AS DEPTNO, NULL AS SLACKER, NULL AS DEPTNO0, NULL AS NAME) AS t WHERE 1 = 0
SELECT EMP.SAL FROM EMP AS EMP WHERE CASE WHEN EMP.SAL = 1000 THEN CASE WHEN EMP.SAL = 1000 THEN NULL ELSE 1 END IS NULL ELSE CASE WHEN EMP.SAL = 2000 THEN NULL ELSE 1 END IS NULL END IS TRUE
SELECT EMP0.SAL FROM EMP AS EMP0 WHERE CASE WHEN EMP0.SAL = 1000 THEN EMP0.SAL = 1000 ELSE EMP0.SAL = 2000 END
SELECT 1 FROM EMP AS EMP RIGHT JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO > 9) AS t ON EMP.DEPTNO = t.DEPTNO WHERE EMP.DEPTNO > 7
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 9) AS t2 RIGHT JOIN (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO > 9) AS t3 ON t2.DEPTNO = t3.DEPTNO WHERE t2.DEPTNO > 7
SELECT EMP.DEPTNO, COUNT(DISTINCT EMP.ENAME) AS CDE, COUNT(DISTINCT EMP.JOB, EMP.ENAME) AS CDJE, COUNT(DISTINCT EMP.DEPTNO, EMP.JOB) AS CDDJ, SUM(EMP.SAL) AS S FROM EMP AS EMP GROUP BY EMP.DEPTNO
SELECT DEPTNO, COUNT(ENAME) FILTER (WHERE $g_1) AS CDE, COUNT(JOB, ENAME) FILTER (WHERE $g_0) AS CDJE, COUNT(DEPTNO, JOB) FILTER (WHERE $g_2) AS CDDJ, CAST(MIN(S) FILTER (WHERE $g_3) AS INTEGER) AS S FROM (SELECT DEPTNO, ENAME, JOB, SUM(SAL) AS S, GROUPING(DEPTNO, ENAME, JOB) = 0 AS $g_0, GROUPING(DEPTNO, ENAME, JOB) = 1 AS $g_1, GROUPING(DEPTNO, ENAME, JOB) = 2 AS $g_2, GROUPING(DEPTNO, ENAME, JOB) = 3 AS $g_3 FROM EMP GROUP BY GROUPING SETS((ENAME, JOB, DEPTNO), (ENAME, DEPTNO), (JOB, DEPTNO), DEPTNO)) AS t0 GROUP BY DEPTNO
SELECT DEPTNO, JOB, SUM(U) FROM (SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER, CAST(NULL AS INTEGER) AS U FROM EMP UNION ALL SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER, CAST(NULL AS INTEGER) AS U FROM EMP) AS t1 GROUP BY ROLLUP(DEPTNO, JOB)
SELECT DEPTNO, JOB, SUM(EXPR$2) FROM (SELECT DEPTNO, JOB, SUM(CAST(NULL AS INTEGER)) AS EXPR$2 FROM EMP GROUP BY DEPTNO, JOB UNION ALL SELECT DEPTNO, JOB, SUM(CAST(NULL AS INTEGER)) AS EXPR$2 FROM EMP GROUP BY DEPTNO, JOB) AS t3 GROUP BY ROLLUP(DEPTNO, JOB)
SELECT EMP.EMPNO FROM EMP AS EMP WHERE EMP.EMPNO < CASE WHEN EMP.DEPTNO IN (SELECT CASE WHEN TRUE THEN EMP0.DEPTNO ELSE NULL END FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20) = TRUE THEN 10 WHEN EMP.DEPTNO IN (SELECT CASE WHEN TRUE THEN EMP1.DEPTNO ELSE NULL END FROM EMP AS EMP1 WHERE EMP1.EMPNO < 20) = FALSE THEN 20 ELSE 30 END
SELECT EMP.EMPNO FROM EMP CROSS JOIN (SELECT COUNT(*) AS c, COUNT(CASE WHEN TRUE THEN CAST(DEPTNO AS INTEGER) ELSE NULL END) AS ck FROM EMP WHERE EMPNO < 20) AS t1 LEFT JOIN (SELECT CASE WHEN TRUE THEN CAST(DEPTNO AS INTEGER) ELSE NULL END AS EXPR$0, TRUE AS i FROM EMP WHERE EMPNO < 20 GROUP BY CASE WHEN TRUE THEN CAST(DEPTNO AS INTEGER) ELSE NULL END, TRUE) AS t4 ON EMP.DEPTNO = t4.EXPR$0 WHERE EMP.EMPNO < CASE WHEN CASE WHEN t1.c = 0 THEN FALSE WHEN t4.i IS NOT NULL THEN TRUE WHEN t1.ck < t1.c THEN NULL ELSE FALSE END = TRUE THEN 10 WHEN CASE WHEN t1.c = 0 THEN FALSE WHEN t4.i IS NOT NULL THEN TRUE WHEN t1.ck < t1.c THEN NULL ELSE FALSE END = FALSE THEN 20 ELSE 30 END
SELECT * FROM (SELECT DEPT.NAME FROM DEPT AS DEPT UNION ALL SELECT DEPT0.NAME FROM DEPT AS DEPT0) AS T1 ORDER BY T1.NAME
SELECT * FROM ((SELECT NAME FROM DEPT ORDER BY NAME) UNION ALL (SELECT NAME FROM DEPT ORDER BY NAME)) AS T1 ORDER BY NAME
SELECT * FROM (SELECT DEPT.NAME FROM DEPT AS DEPT UNION ALL SELECT DEPT0.NAME FROM DEPT AS DEPT0) AS T1 ORDER BY T1.NAME FETCH NEXT 0 ROWS ONLY
SELECT * FROM ((SELECT NAME FROM DEPT ORDER BY NAME FETCH NEXT 0 ROWS ONLY) UNION ALL (SELECT NAME FROM DEPT ORDER BY NAME FETCH NEXT 0 ROWS ONLY)) AS T1 ORDER BY NAME FETCH NEXT 0 ROWS ONLY
SELECT 1 FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO > 7 AND EMP.COMM = EMP.DEPTNO AND EMP.COMM + EMP.DEPTNO > EMP.COMM / 2) AS t INNER JOIN (SELECT * FROM EMP AS EMP0 WHERE EMP0.SAL = EMP0.DEPTNO) AS t0 ON t.DEPTNO = t0.DEPTNO
SELECT 1 FROM (SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO > 7 AND EMP1.COMM = EMP1.DEPTNO AND EMP1.COMM + EMP1.DEPTNO > EMP1.COMM / 2) AS t2 INNER JOIN (SELECT * FROM (SELECT * FROM EMP AS EMP2 WHERE EMP2.SAL = EMP2.DEPTNO) AS t3 WHERE t3.DEPTNO > 7) AS t4 ON t2.DEPTNO = t4.DEPTNO
SELECT EMP.EMPNO FROM EMP AS EMP WHERE (((SELECT EMP0.DEPTNO FROM EMP AS EMP0 WHERE EMP0.EMPNO < 20))) < (((SELECT EMP1.DEPTNO FROM EMP AS EMP1 WHERE EMP1.EMPNO > 100))) OR EMP.SAL < 100
SELECT EMP2.EMPNO FROM EMP AS EMP2 LEFT JOIN (SELECT SINGLE_VALUE(EMP3.DEPTNO) AS $f0 FROM EMP AS EMP3 WHERE EMP3.EMPNO < 20) AS t7 ON TRUE LEFT JOIN (SELECT SINGLE_VALUE(EMP4.DEPTNO) AS $f0 FROM EMP AS EMP4 WHERE EMP4.EMPNO > 100) AS t10 ON TRUE WHERE t7.$f0 < t10.$f0 OR EMP2.SAL < 100
SELECT * FROM (VALUES (1,2)) WHERE FALSE
SELECT * FROM (SELECT NULL AS EXPR$0, NULL AS EXPR$1) AS t WHERE 1 = 0
SELECT t.ENAME, MAX(t.MGR) FROM (SELECT * FROM EMP AS EMP UNION ALL SELECT * FROM EMP AS EMP0) AS t GROUP BY t.ENAME
SELECT t6.ENAME, MAX(t6.max1) FROM (SELECT EMP1.ENAME, MAX(EMP1.MGR) as max1 FROM EMP AS EMP1 GROUP BY EMP1.ENAME UNION ALL SELECT EMP2.ENAME, MAX(EMP2.MGR) as max1 FROM EMP AS EMP2 GROUP BY EMP2.ENAME) AS t6 GROUP BY t6.ENAME
SELECT 2, EMP.DEPTNO, EMP.JOB FROM EMP AS EMP UNION ALL SELECT 1, EMP0.DEPTNO, EMP0.JOB FROM EMP AS EMP0
SELECT 2, EMP1.DEPTNO, EMP1.JOB FROM EMP AS EMP1 UNION ALL SELECT 1, EMP2.DEPTNO, EMP2.JOB FROM EMP AS EMP2
SELECT 2, 3 FROM EMP AS EMP UNION ALL SELECT 2, 3 FROM EMP AS EMP0
SELECT 2, 3 FROM (SELECT 2 FROM EMP AS EMP1 UNION ALL SELECT 2 FROM EMP AS EMP2) AS t6
SELECT COUNT(*), CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END FROM EMP AS EMP RIGHT JOIN BONUS AS BONUS ON EMP.ENAME = BONUS.ENAME GROUP BY CASE WHEN EMP.SAL < 11 THEN 11 ELSE -1 * EMP.SAL END
SELECT COUNT(*), CASE WHEN t2.expr1 THEN 11 ELSE t2.expr2 END FROM (SELECT EMP0.ENAME, EMP0.SAL < 11 AS expr1, -1 * EMP0.SAL AS expr2 FROM EMP AS EMP0) AS t2 RIGHT JOIN (SELECT BONUS0.ENAME FROM BONUS AS BONUS0) AS t3 ON t2.ENAME = t3.ENAME GROUP BY CASE WHEN t2.expr1 THEN 11 ELSE t2.expr2 END
SELECT * FROM (SELECT * FROM EMP AS EMP WHERE EMP.DEPTNO = 10 UNION SELECT * FROM EMP AS EMP0 WHERE EMP0.DEPTNO = 20) AS t1 UNION ALL SELECT * FROM EMP AS EMP1 WHERE EMP1.DEPTNO = 30
SELECT * FROM (SELECT * FROM EMP AS EMP2 WHERE EMP2.DEPTNO = 10 UNION SELECT * FROM EMP AS EMP3 WHERE EMP3.DEPTNO = 20) AS t6 UNION ALL SELECT * FROM EMP AS EMP4 WHERE EMP4.DEPTNO = 30