|
| 1 | +statement ok |
| 2 | +CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER, e INTEGER) |
| 3 | + |
| 4 | +statement ok |
| 5 | +INSERT INTO t1(e,c,b,d,a) VALUES(103,102,100,101,104) |
| 6 | + |
| 7 | +statement ok |
| 8 | +INSERT INTO t1(a,c,d,e,b) VALUES(107,106,108,109,105) |
| 9 | + |
| 10 | +statement ok |
| 11 | +INSERT INTO t1(e,d,b,a,c) VALUES(110,114,112,111,113) |
| 12 | + |
| 13 | +statement ok |
| 14 | +INSERT INTO t1(d,c,e,a,b) VALUES(116,119,117,115,118) |
| 15 | + |
| 16 | +statement ok |
| 17 | +INSERT INTO t1(c,d,b,e,a) VALUES(123,122,124,120,121) |
| 18 | + |
| 19 | +statement ok |
| 20 | +INSERT INTO t1(a,d,b,e,c) VALUES(127,128,129,126,125) |
| 21 | + |
| 22 | +statement ok |
| 23 | +INSERT INTO t1(e,c,a,d,b) VALUES(132,134,131,133,130) |
| 24 | + |
| 25 | +statement ok |
| 26 | +INSERT INTO t1(a,d,b,e,c) VALUES(138,136,139,135,137) |
| 27 | + |
| 28 | +statement ok |
| 29 | +INSERT INTO t1(e,c,d,a,b) VALUES(144,141,140,142,143) |
| 30 | + |
| 31 | +statement ok |
| 32 | +INSERT INTO t1(b,a,e,d,c) VALUES(145,149,146,148,147) |
| 33 | + |
| 34 | +statement ok |
| 35 | +INSERT INTO t1(b,c,a,d,e) VALUES(151,150,153,154,152) |
| 36 | + |
| 37 | +statement ok |
| 38 | +INSERT INTO t1(c,e,a,d,b) VALUES(155,157,159,156,158) |
| 39 | + |
| 40 | +statement ok |
| 41 | +INSERT INTO t1(c,b,a,d,e) VALUES(161,160,163,164,162) |
| 42 | + |
| 43 | +statement ok |
| 44 | +INSERT INTO t1(b,d,a,e,c) VALUES(167,169,168,165,166) |
| 45 | + |
| 46 | +statement ok |
| 47 | +INSERT INTO t1(d,b,c,e,a) VALUES(171,170,172,173,174) |
| 48 | + |
| 49 | +statement ok |
| 50 | +INSERT INTO t1(e,c,a,d,b) VALUES(177,176,179,178,175) |
| 51 | + |
| 52 | +statement ok |
| 53 | +INSERT INTO t1(b,e,a,d,c) VALUES(181,180,182,183,184) |
| 54 | + |
| 55 | +statement ok |
| 56 | +INSERT INTO t1(c,a,b,e,d) VALUES(187,188,186,189,185) |
| 57 | + |
| 58 | +statement ok |
| 59 | +INSERT INTO t1(d,b,c,e,a) VALUES(190,194,193,192,191) |
| 60 | + |
| 61 | +statement ok |
| 62 | +INSERT INTO t1(a,e,b,d,c) VALUES(199,197,198,196,195) |
| 63 | + |
| 64 | +statement ok |
| 65 | +INSERT INTO t1(b,c,d,a,e) VALUES(200,202,203,201,204) |
| 66 | + |
| 67 | +statement ok |
| 68 | +INSERT INTO t1(c,e,a,b,d) VALUES(208,209,205,206,207) |
| 69 | + |
| 70 | +statement ok |
| 71 | +INSERT INTO t1(c,e,a,d,b) VALUES(214,210,213,212,211) |
| 72 | + |
| 73 | +statement ok |
| 74 | +INSERT INTO t1(b,c,a,d,e) VALUES(218,215,216,217,219) |
| 75 | + |
| 76 | +statement ok |
| 77 | +INSERT INTO t1(b,e,d,a,c) VALUES(223,221,222,220,224) |
| 78 | + |
| 79 | +statement ok |
| 80 | +INSERT INTO t1(d,e,b,a,c) VALUES(226,227,228,229,225) |
| 81 | + |
| 82 | +statement ok |
| 83 | +INSERT INTO t1(a,c,b,e,d) VALUES(234,231,232,230,233) |
| 84 | + |
| 85 | +statement ok |
| 86 | +INSERT INTO t1(e,b,a,c,d) VALUES(237,236,239,235,238) |
| 87 | + |
| 88 | +statement ok |
| 89 | +INSERT INTO t1(e,c,b,a,d) VALUES(242,244,240,243,241) |
| 90 | + |
| 91 | +statement ok |
| 92 | +INSERT INTO t1(e,d,c,b,a) VALUES(246,248,247,249,245) |
| 93 | + |
| 94 | +skipif PostgreSQL # FoundationDB bug 1191988 CASE statement with AVG |
| 95 | +query I nosort |
| 96 | +SELECT CASE WHEN c>(SELECT avg(c) FROM t1) THEN a*2 ELSE b*10 END |
| 97 | + FROM t1 |
| 98 | + ORDER BY 1 |
| 99 | +---- |
| 100 | +30 values hashing to 3c13dee48d9356ae19af2515e05e6b54 |
| 101 | + |
| 102 | +query II nosort |
| 103 | +SELECT a+b*2+c*3+d*4+e*5, |
| 104 | + (a+b+c+d+e)/5 |
| 105 | + FROM t1 |
| 106 | + ORDER BY 1,2 |
| 107 | +---- |
| 108 | +60 values hashing to 808146289313018fce25f1a280bd8c30 |
| 109 | + |
| 110 | +query IIIII nosort |
| 111 | +SELECT a+b*2+c*3+d*4+e*5, |
| 112 | + CASE WHEN a<b-3 THEN 111 WHEN a<=b THEN 222 |
| 113 | + WHEN a<b+3 THEN 333 ELSE 444 END, |
| 114 | + abs(b-c), |
| 115 | + (a+b+c+d+e)/5, |
| 116 | + a+b*2+c*3 |
| 117 | + FROM t1 |
| 118 | + WHERE (e>c OR e<d) |
| 119 | + AND d>e |
| 120 | + AND EXISTS(SELECT 1 FROM t1 AS x WHERE x.b<t1.b) |
| 121 | + ORDER BY 4,2,1,3,5 |
| 122 | +---- |
| 123 | +80 values hashing to f588aa173060543daffc54d07638516f |
| 124 | + |
| 125 | +skipif PostgreSQL # FoundationDB bug 1205056 default CASE format not supported |
| 126 | +query IIIII nosort |
| 127 | +SELECT c, |
| 128 | + d-e, |
| 129 | + CASE a+1 WHEN b THEN 111 WHEN c THEN 222 |
| 130 | + WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END, |
| 131 | + a+b*2+c*3+d*4, |
| 132 | + e |
| 133 | + FROM t1 |
| 134 | + WHERE d NOT BETWEEN 110 AND 150 |
| 135 | + OR c BETWEEN b-2 AND d+2 |
| 136 | + OR (e>c OR e<d) |
| 137 | + ORDER BY 1,5,3,2,4 |
| 138 | +---- |
| 139 | +145 values hashing to 1e4da6adbf79506920a0b1e379d830d8 |
| 140 | + |
| 141 | +skipif PostgreSQL # FoundationDB bug 1205056 default CASE format not supported |
| 142 | +query IIIIII nosort |
| 143 | +SELECT a+b*2+c*3+d*4, |
| 144 | + (a+b+c+d+e)/5, |
| 145 | + abs(a), |
| 146 | + e, |
| 147 | + CASE a+1 WHEN b THEN 111 WHEN c THEN 222 |
| 148 | + WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END, |
| 149 | + d |
| 150 | + FROM t1 |
| 151 | + WHERE b>c |
| 152 | + AND c>d |
| 153 | + ORDER BY 3,4,5,1,2,6 |
| 154 | +---- |
| 155 | +24 values hashing to 425542fc8d1ec04f89534ae98d59a74d |
| 156 | + |
| 157 | +skipif PostgreSQL # FoundationDB bug 1205056 default CASE format not supported |
| 158 | +query IIII nosort |
| 159 | +SELECT a+b*2+c*3+d*4, |
| 160 | + CASE a+1 WHEN b THEN 111 WHEN c THEN 222 |
| 161 | + WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END, |
| 162 | + (SELECT count(*) FROM t1 AS x WHERE x.c>t1.c AND x.d<t1.d), |
| 163 | + c |
| 164 | + FROM t1 |
| 165 | + WHERE (c<=d-2 OR c>=d+2) |
| 166 | + ORDER BY 4,2,1,3 |
| 167 | +---- |
| 168 | +60 values hashing to a2af299d7b2197866b7c8f6854b77ab5 |
| 169 | + |
| 170 | +skipif PostgreSQL # FoundationDB bug 1205056 default CASE format not supported |
| 171 | +query I nosort |
| 172 | +SELECT CASE a+1 WHEN b THEN 111 WHEN c THEN 222 |
| 173 | + WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END |
| 174 | + FROM t1 |
| 175 | + ORDER BY 1 |
| 176 | +---- |
| 177 | +30 values hashing to f2bf77f8cfb62666ab72c866ed4d4f1a |
| 178 | + |
| 179 | +query I nosort |
| 180 | +SELECT (SELECT count(*) FROM t1 AS x WHERE x.b<t1.b) |
| 181 | + FROM t1 |
| 182 | + WHERE (a>b-2 AND a<b+2) |
| 183 | + OR c>d |
| 184 | + ORDER BY 1 |
| 185 | +---- |
| 186 | +20 values hashing to 1d6b8ed1db696a5f1c8d126facddd077 |
| 187 | + |
| 188 | +skipif PostgreSQL # FoundationDB bug 1205056 default CASE format not supported |
| 189 | +query IIIII nosort |
| 190 | +SELECT a, |
| 191 | + (SELECT count(*) FROM t1 AS x WHERE x.c>t1.c AND x.d<t1.d), |
| 192 | + b-c, |
| 193 | + a-b, |
| 194 | + CASE a+1 WHEN b THEN 111 WHEN c THEN 222 |
| 195 | + WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END |
| 196 | + FROM t1 |
| 197 | + WHERE c BETWEEN b-2 AND d+2 |
| 198 | + OR a>b |
| 199 | + OR b>c |
| 200 | + ORDER BY 1,4,3,2,5 |
| 201 | +---- |
| 202 | +145 values hashing to 65042db64d506f67a37c85f825cdd11f |
| 203 | + |
| 204 | + |
| 205 | +query I nosort |
| 206 | +SELECT e |
| 207 | + FROM t1 |
| 208 | + WHERE b>c |
| 209 | + AND d>e |
| 210 | + ORDER BY 1 |
| 211 | +---- |
| 212 | +120 |
| 213 | +126 |
| 214 | +135 |
| 215 | +152 |
| 216 | +165 |
| 217 | +230 |
| 218 | +237 |
| 219 | +246 |
| 220 | + |
| 221 | +query II nosort |
| 222 | +SELECT b, |
| 223 | + e |
| 224 | + FROM t1 |
| 225 | + WHERE (c<=d-2 OR c>=d+2) |
| 226 | + ORDER BY 2,1 |
| 227 | +---- |
| 228 | +30 values hashing to e2107ed9f44c1f14fa1a14b1818a2073 |
0 commit comments