Unverified 提交 8f3a8e36 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1474 from katzyn/tests

Detect ordered result sets in TestScript properly
......@@ -21,6 +21,14 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Issue #1473: TestScript needs better detection of sorted result
</li>
<li>PR #1471: issue 1350: TestCrashAPI: PageStore.freeListPagesPerList
</li>
<li>PR #1470: Fix window functions in queries with HAVING
</li>
<li>PR #1469: Forbid incorrect nesting of aggregates and window functions
</li>
<li>Issue #1437: Generated as Identity has a different behaviour.
</li>
<li>PR #1467: Fix subtraction of timestamps
......
......@@ -20,14 +20,20 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.h2.api.ErrorCode;
import org.h2.command.CommandContainer;
import org.h2.command.CommandInterface;
import org.h2.command.Prepared;
import org.h2.command.dml.Query;
import org.h2.engine.SysProperties;
import org.h2.jdbc.JdbcConnection;
import org.h2.jdbc.JdbcPreparedStatement;
import org.h2.test.TestAll;
import org.h2.test.TestBase;
import org.h2.test.TestDb;
......@@ -41,6 +47,12 @@ public class TestScript extends TestDb {
private static final String BASE_DIR = "org/h2/test/scripts/";
private static final Field COMMAND;
private static final Field PREPARED;
private static boolean CHECK_ORDERING;
/** If set to true, the test will exit at the first failure. */
private boolean failFast;
/** If set to a value the test will add all executed statements to this list */
......@@ -53,17 +65,29 @@ public class TestScript extends TestDb {
private LineNumberReader in;
private PrintStream out;
private final ArrayList<String[]> result = new ArrayList<>();
private String putBack;
private final ArrayDeque<String> putBack = new ArrayDeque<>();
private StringBuilder errors;
private Random random = new Random(1);
static {
try {
COMMAND = JdbcPreparedStatement.class.getDeclaredField("command");
COMMAND.setAccessible(true);
PREPARED = CommandContainer.class.getDeclaredField("prepared");
PREPARED.setAccessible(true);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
/**
* Run just this test.
*
* @param a ignored
*/
public static void main(String... a) throws Exception {
CHECK_ORDERING = true;
TestBase.createCaller().init().test();
}
......@@ -199,7 +223,7 @@ public class TestScript extends TestDb {
in = null;
out = null;
result.clear();
putBack = null;
putBack.clear();
errors = null;
if (statements == null) {
......@@ -224,16 +248,13 @@ public class TestScript extends TestDb {
}
private String readLine() throws IOException {
if (putBack != null) {
String s = putBack;
putBack = null;
return s;
}
while (true) {
String s = in.readLine();
if (s == null) {
return null;
String s = putBack.pollFirst();
return s != null ? s : readNextLine();
}
private String readNextLine() throws IOException {
String s;
while ((s = in.readLine()) != null) {
if (s.startsWith("#")) {
int end = s.indexOf('#', 1);
if (end < 3) {
......@@ -265,10 +286,15 @@ public class TestScript extends TestDb {
}
}
s = s.trim();
if (s.length() > 0) {
return s;
if (!s.isEmpty()) {
break;
}
}
return s;
}
public void putBack(String line) {
putBack.addLast(line);
}
private void testFile(String inFile, boolean allowReconnect) throws Exception {
......@@ -418,10 +444,20 @@ public class TestScript extends TestDb {
private int processStatement(String sql) throws Exception {
try {
if (stat.execute(sql)) {
writeResultSet(sql, stat.getResultSet());
boolean res;
Statement s;
if (/* TestScript */ CHECK_ORDERING || /* TestAll */ config.memory && !config.lazy && !config.networked) {
PreparedStatement prep = conn.prepareStatement(sql);
res = prep.execute();
s = prep;
} else {
res = stat.execute(sql);
s = stat;
}
if (res) {
writeResultSet(sql, s.getResultSet());
} else {
int count = stat.getUpdateCount();
int count = s.getUpdateCount();
writeResult(sql, count < 1 ? "ok" : "update count: " + count, null);
}
} catch (SQLException e) {
......@@ -448,7 +484,6 @@ public class TestScript extends TestDb {
}
private void writeResultSet(String sql, ResultSet rs) throws Exception {
boolean ordered = StringUtils.toLowerEnglish(sql).contains("order by");
ResultSetMetaData meta = rs.getMetaData();
int len = meta.getColumnCount();
int[] max = new int[len];
......@@ -472,9 +507,20 @@ public class TestScript extends TestDb {
}
head[i] = label;
}
Boolean gotOrdered = null;
Statement st = rs.getStatement();
if (st instanceof JdbcPreparedStatement) {
CommandInterface ci = (CommandInterface) COMMAND.get(st);
if (ci instanceof CommandContainer) {
Prepared p = (Prepared) PREPARED.get(ci);
if (p instanceof Query) {
gotOrdered = ((Query) p).hasOrder();
}
}
}
rs.close();
String line = readLine();
putBack = line;
putBack(line);
if (line != null && line.startsWith(">> ")) {
switch (result.size()) {
case 0:
......@@ -493,20 +539,52 @@ public class TestScript extends TestDb {
return;
}
}
Boolean ordered;
for (;;) {
line = readNextLine();
if (line == null) {
addWriteResultError("<row count>", "<eof>");
return;
}
putBack(line);
if (line.startsWith("> rows: ")) {
ordered = false;
break;
} else if (line.startsWith("> rows (ordered): ")) {
ordered = true;
break;
} else if (line.startsWith("> rows (partially ordered): ")) {
ordered = null;
break;
}
}
if (gotOrdered != null) {
if (ordered == null || ordered) {
if (!gotOrdered) {
addWriteResultError("<ordered result set>", "<result set>");
}
} else {
if (gotOrdered) {
addWriteResultError("<result set>", "<ordered result set>");
}
}
}
writeResult(sql, format(head, max), null);
writeResult(sql, format(null, max), null);
String[] array = new String[result.size()];
for (int i = 0; i < result.size(); i++) {
array[i] = format(result.get(i), max);
}
if (!ordered) {
if (!Boolean.TRUE.equals(ordered)) {
sort(array);
}
int i = 0;
for (; i < array.length; i++) {
writeResult(sql, array[i], null);
}
writeResult(sql, (ordered ? "rows (ordered): " : "rows: ") + i, null);
writeResult(sql,
(ordered != null ? ordered ? "rows (ordered): " : "rows: " : "rows (partially ordered): ") + i,
null);
}
private static String format(String[] row, int[] max) {
......@@ -575,7 +653,7 @@ public class TestScript extends TestDb {
}
} else {
addWriteResultError("<nothing>", s);
putBack = compare;
putBack(compare);
}
write(s);
}
......
......@@ -25,7 +25,7 @@ SELECT * FROM TEST ORDER BY A, B;
> 2 2 1
> 2 2 2
> 2 2 3
> rows (ordered): 12
> rows (partially ordered): 12
SELECT * FROM TEST ORDER BY A, B, C FETCH FIRST 4 ROWS ONLY;
> A B C
......@@ -43,7 +43,7 @@ SELECT * FROM TEST ORDER BY A, B, C FETCH FIRST 4 ROWS WITH TIES;
> 1 1 2
> 1 1 3
> 1 2 1
> rows: 4
> rows (ordered): 4
SELECT * FROM TEST ORDER BY A, B FETCH FIRST 4 ROWS WITH TIES;
> A B C
......@@ -54,7 +54,7 @@ SELECT * FROM TEST ORDER BY A, B FETCH FIRST 4 ROWS WITH TIES;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 6
> rows (partially ordered): 6
SELECT * FROM TEST ORDER BY A FETCH FIRST ROW WITH TIES;
> A B C
......@@ -65,7 +65,7 @@ SELECT * FROM TEST ORDER BY A FETCH FIRST ROW WITH TIES;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 6
> rows (partially ordered): 6
SELECT TOP (1) WITH TIES * FROM TEST ORDER BY A;
> A B C
......@@ -76,7 +76,7 @@ SELECT TOP (1) WITH TIES * FROM TEST ORDER BY A;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 6
> rows (partially ordered): 6
SELECT TOP 1 PERCENT WITH TIES * FROM TEST ORDER BY A;
> A B C
......@@ -87,7 +87,7 @@ SELECT TOP 1 PERCENT WITH TIES * FROM TEST ORDER BY A;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 6
> rows (partially ordered): 6
SELECT TOP 51 PERCENT WITH TIES * FROM TEST ORDER BY A, B;
> A B C
......@@ -101,7 +101,7 @@ SELECT TOP 51 PERCENT WITH TIES * FROM TEST ORDER BY A, B;
> 2 1 1
> 2 1 2
> 2 1 3
> rows: 9
> rows (partially ordered): 9
SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> A B C
......@@ -109,7 +109,7 @@ SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 3
> rows (partially ordered): 3
SELECT * FROM TEST FETCH NEXT ROWS ONLY;
> A B C
......@@ -163,7 +163,7 @@ SELECT * FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 6
> rows (partially ordered): 6
SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> A B C
......@@ -171,7 +171,7 @@ SELECT * FROM TEST ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 1 ROW WITH TIES;
> 1 2 1
> 1 2 2
> 1 2 3
> rows: 3
> rows (partially ordered): 3
SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> exception WITH_TIES_WITHOUT_ORDER_BY
......@@ -183,7 +183,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> 1 2 2
> 1 2 3
> 1 2 4
> rows: 4
> rows (partially ordered): 4
(SELECT * FROM TEST) UNION (SELECT 1, 2, 4) ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 50 PERCENT ROWS ONLY;
> A B C
......@@ -195,7 +195,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> 2 1 1
> 2 1 2
> 2 1 3
> rows: 7
> rows (partially ordered): 7
(SELECT * FROM TEST) UNION (SELECT 1, 2, 4) ORDER BY A, B OFFSET 3 ROWS FETCH NEXT 40 PERCENT ROWS WITH TIES;
> A B C
......@@ -207,7 +207,7 @@ SELECT * FROM TEST FETCH FIRST 1 ROW WITH TIES;
> 2 1 1
> 2 1 2
> 2 1 3
> rows: 7
> rows (partially ordered): 7
(SELECT * FROM TEST) UNION (SELECT 1, 2, 4) FETCH NEXT 1 ROW WITH TIES;
> exception WITH_TIES_WITHOUT_ORDER_BY
......@@ -233,7 +233,7 @@ SELECT A, B FROM TEST ORDER BY A FETCH FIRST 1 ROW WITH TIES;
> 0 1
> 0 3
> 0.0 2
> rows: 3
> rows (partially ordered): 3
DROP TABLE TEST;
> ok
......
......@@ -60,35 +60,35 @@ SHOW TABLES;
> TABLE_NAME TABLE_SCHEMA
> ---------- ------------
> TEST_P PUBLIC
> rows: 1
> rows (ordered): 1
SHOW TABLES FROM PUBLIC;
> TABLE_NAME TABLE_SCHEMA
> ---------- ------------
> TEST_P PUBLIC
> rows: 1
> rows (ordered): 1
SHOW TABLES FROM SCH;
> TABLE_NAME TABLE_SCHEMA
> ---------- ------------
> TEST_S SCH
> rows: 1
> rows (ordered): 1
SHOW COLUMNS FROM TEST_P;
> FIELD TYPE NULL KEY DEFAULT
> ----- ------------ ---- --- -------
> ID_P INTEGER(10) NO PRI NULL
> N_P INTEGER(10) YES 1
> U_P VARCHAR(255) YES UNI NULL
> rows: 3
> N_P INTEGER(10) YES 1
> rows (ordered): 3
SHOW COLUMNS FROM TEST_S FROM SCH;
> FIELD TYPE NULL KEY DEFAULT
> ----- ------------ ---- --- -------
> ID_S INTEGER(10) NO PRI NULL
> N_S INTEGER(10) YES 1
> U_S VARCHAR(255) YES UNI NULL
> rows: 3
> N_S INTEGER(10) YES 1
> rows (ordered): 3
SHOW DATABASES;
> SCHEMA_NAME
......
......@@ -17,7 +17,7 @@ select array_agg(v order by v asc),
> ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4'))
> ------------------------ ------------------------------------------------------
> (2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4)
> rows (ordered): 1
> rows: 1
create index test_idx on test(v);
> ok
......@@ -28,7 +28,7 @@ select ARRAY_AGG(v order by v asc),
> ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4'))
> ------------------------ ------------------------------------------------------
> (2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4)
> rows (ordered): 1
> rows: 1
select ARRAY_AGG(v order by v asc),
ARRAY_AGG(v order by v desc) filter (where v >= '4')
......@@ -36,7 +36,7 @@ select ARRAY_AGG(v order by v asc),
> ARRAY_AGG(V ORDER BY V) ARRAY_AGG(V ORDER BY V DESC) FILTER (WHERE (V >= '4'))
> --------------------------- ------------------------------------------------------
> (1, 2, 3, 4, 5, 6, 7, 8, 9) (9, 8, 7, 6, 5, 4)
> rows (ordered): 1
> rows: 1
drop table test;
> ok
......@@ -63,7 +63,7 @@ select array_agg(distinct v order by v desc) from test;
> ARRAY_AGG(DISTINCT V ORDER BY V DESC)
> -------------------------------------
> (9, 8, 7, 3, 2, -1)
> rows (ordered): 1
> rows: 1
drop table test;
> ok
......@@ -77,7 +77,7 @@ INSERT INTO TEST VALUES (1, 'a'), (2, 'a'), (3, 'b'), (4, 'c'), (5, 'c'), (6, 'c
SELECT ARRAY_AGG(ID), NAME FROM TEST;
> exception MUST_GROUP_BY_COLUMN_1
SELECT ARRAY_AGG(ID ORDER /**/ BY ID), NAME FROM TEST GROUP BY NAME;
SELECT ARRAY_AGG(ID ORDER BY ID), NAME FROM TEST GROUP BY NAME;
> ARRAY_AGG(ID ORDER BY ID) NAME
> ------------------------- ----
> (1, 2) a
......@@ -85,7 +85,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID), NAME FROM TEST GROUP BY NAME;
> (4, 5, 6) c
> rows: 3
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (), NAME FROM TEST;
SELECT ARRAY_AGG(ID ORDER BY ID) OVER (), NAME FROM TEST;
> ARRAY_AGG(ID ORDER BY ID) OVER () NAME
> --------------------------------- ----
> (1, 2, 3, 4, 5, 6) a
......@@ -96,7 +96,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (), NAME FROM TEST;
> (1, 2, 3, 4, 5, 6) c
> rows: 6
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (PARTITION BY NAME), NAME FROM TEST;
SELECT ARRAY_AGG(ID ORDER BY ID) OVER (PARTITION BY NAME), NAME FROM TEST;
> ARRAY_AGG(ID ORDER BY ID) OVER (PARTITION BY NAME) NAME
> -------------------------------------------------- ----
> (1, 2) a
......@@ -107,7 +107,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER (PARTITION BY NAME), NAME FROM TEST;
> (4, 5, 6) c
> rows: 6
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) FILTER (WHERE ID < 3 OR ID > 4) OVER (PARTITION BY NAME), NAME FROM TEST ORDER BY NAME;
SELECT ARRAY_AGG(ID ORDER BY ID) FILTER (WHERE ID < 3 OR ID > 4) OVER (PARTITION BY NAME), NAME FROM TEST ORDER BY NAME;
> ARRAY_AGG(ID ORDER BY ID) FILTER (WHERE ((ID < 3) OR (ID > 4))) OVER (PARTITION BY NAME) NAME
> ---------------------------------------------------------------------------------------- ----
> (1, 2) a
......@@ -124,7 +124,7 @@ SELECT ARRAY_AGG(SUM(ID)) OVER () FROM TEST;
> (21)
> rows: 1
SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER() FROM TEST GROUP BY ID ORDER /**/ BY ID;
SELECT ARRAY_AGG(ID ORDER BY ID) OVER() FROM TEST GROUP BY ID ORDER BY ID;
> ARRAY_AGG(ID ORDER BY ID) OVER ()
> ---------------------------------
> (1, 2, 3, 4, 5, 6)
......@@ -133,7 +133,7 @@ SELECT ARRAY_AGG(ID ORDER /**/ BY ID) OVER() FROM TEST GROUP BY ID ORDER /**/ BY
> (1, 2, 3, 4, 5, 6)
> (1, 2, 3, 4, 5, 6)
> (1, 2, 3, 4, 5, 6)
> rows: 6
> rows (ordered): 6
SELECT ARRAY_AGG(NAME) OVER(PARTITION BY NAME) FROM TEST GROUP BY NAME;
> ARRAY_AGG(NAME) OVER (PARTITION BY NAME)
......@@ -143,7 +143,7 @@ SELECT ARRAY_AGG(NAME) OVER(PARTITION BY NAME) FROM TEST GROUP BY NAME;
> (c)
> rows: 3
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST GROUP BY NAME;
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST GROUP BY NAME;
> ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME) NAME
> ------------------------------------------------------------- ----
> ((1, 2)) a
......@@ -151,13 +151,13 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME
> ((4, 5, 6)) c
> rows: 3
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER /**/ BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST
GROUP BY NAME ORDER /**/ BY NAME OFFSET 1 ROW;
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME), NAME FROM TEST
GROUP BY NAME ORDER BY NAME OFFSET 1 ROW;
> ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME) NAME
> ------------------------------------------------------------- ----
> ((3)) b
> ((4, 5, 6)) c
> rows: 2
> rows (ordered): 2
SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) FILTER (WHERE NAME > 'b') OVER (PARTITION BY NAME), NAME FROM TEST
GROUP BY NAME ORDER BY NAME;
......@@ -196,7 +196,7 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) FILTER (WHERE NAME > 'c') OVER () FR
SELECT ARRAY_AGG(ID) OVER() FROM TEST GROUP BY NAME;
> exception MUST_GROUP_BY_COLUMN_1
SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID), NAME FROM TEST;
SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER BY ID), NAME FROM TEST;
> ARRAY_AGG(ID) OVER (PARTITION BY NAME ORDER BY ID) NAME
> -------------------------------------------------- ----
> (1) a
......@@ -207,7 +207,7 @@ SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID), NAME FROM TEST;
> (4, 5, 6) c
> rows: 6
SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC), NAME FROM TEST;
SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER BY ID DESC), NAME FROM TEST;
> ARRAY_AGG(ID) OVER (PARTITION BY NAME ORDER BY ID DESC) NAME
> ------------------------------------------------------- ----
> (2) a
......@@ -219,8 +219,8 @@ SELECT ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC), NAME FROM TE
> rows: 6
SELECT
ARRAY_AGG(ID ORDER /**/ BY ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC) A,
ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER /**/ BY ID DESC) D,
ARRAY_AGG(ID ORDER BY ID) OVER(PARTITION BY NAME ORDER BY ID DESC) A,
ARRAY_AGG(ID) OVER(PARTITION BY NAME ORDER BY ID DESC) D,
NAME FROM TEST;
> A D NAME
> --------- --------- ----
......@@ -232,7 +232,7 @@ SELECT
> (6) (6) c
> rows: 6
SELECT ARRAY_AGG(SUM(ID)) OVER(ORDER /**/ BY ID) FROM TEST GROUP BY ID;
SELECT ARRAY_AGG(SUM(ID)) OVER(ORDER BY ID) FROM TEST GROUP BY ID;
> ARRAY_AGG(SUM(ID)) OVER (ORDER BY ID)
> -------------------------------------
> (1)
......@@ -266,12 +266,12 @@ SELECT
FROM TEST;
> D R G T N
> --------------- ------------ ------------ --------------- ---------------
> (1, 2, 3, 4, 5) (2, 3, 4, 5) (2, 3, 4, 5) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 3, 4, 5) (1, 5) (1, 2, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 4, 5) (1, 5) (1, 3, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 3, 5) (1, 5) (1, 4, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 3, 4) (1, 2, 3, 4) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5)
> rows (ordered): 5
> (1, 2, 3, 4, 5) (1, 2, 3, 5) (1, 5) (1, 4, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 2, 4, 5) (1, 5) (1, 3, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (1, 3, 4, 5) (1, 5) (1, 2, 5) (1, 2, 3, 4, 5)
> (1, 2, 3, 4, 5) (2, 3, 4, 5) (2, 3, 4, 5) (1, 2, 3, 4, 5) (1, 2, 3, 4, 5)
> rows: 5
DROP TABLE TEST;
> ok
......@@ -309,7 +309,7 @@ SELECT *,
> 6 8 (5, 6, 7) (8, 8, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (3, 4, 5, 6, 7, 8) (5, 8, 8, 8, 9, 9)
> 7 9 (6, 7, 8) (8, 9, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9)
> 8 9 (7, 8) (9, 9) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9) (9, 9, 8, 8, 8) (4, 5, 6, 7, 8) (8, 8, 8, 9, 9)
> rows (ordered): 8
> rows: 8
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE ROWS -1 PRECEDING) FROM TEST;
> exception INVALID_VALUE_2
......@@ -321,7 +321,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 2 PRECEDING AND 1 PRECEDI
> 2 1 (1)
> 3 5 (1, 2)
> 4 8 (2, 3)
> rows (ordered): 4
> rows: 4
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST OFFSET 4 ROWS;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
......@@ -330,7 +330,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWI
> 6 8 (7, 8)
> 7 9 (8)
> 8 9 null
> rows (ordered): 4
> rows: 4
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) FROM TEST FETCH FIRST 4 ROWS ONLY;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING)
......@@ -339,7 +339,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 2 PRECEDING AND 1 PRECED
> 2 1 (1)
> 3 5 (1, 2)
> 4 8 (2, 3)
> rows (ordered): 4
> rows: 4
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST OFFSET 4 ROWS;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
......@@ -348,7 +348,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOW
> 6 8 (7, 8)
> 7 9 (8)
> 8 9 null
> rows (ordered): 4
> rows: 4
SELECT *,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) U_P,
......@@ -366,7 +366,7 @@ SELECT *,
> 6 8 (1, 2, 3) (1, 2, 3) (7, 8) (7, 8)
> 7 9 (1, 2, 3, 4, 5, 6) (3, 4, 5, 6) null null
> 8 9 (1, 2, 3, 4, 5, 6) (3, 4, 5, 6) null null
> rows (ordered): 8
> rows: 8
SELECT *,
ARRAY_AGG(ID) OVER (ORDER BY VALUE GROUPS BETWEEN 1 PRECEDING AND 0 PRECEDING) P,
......@@ -382,7 +382,7 @@ SELECT *,
> 6 8 (3, 4, 5, 6) (4, 5, 6, 7, 8)
> 7 9 (4, 5, 6, 7, 8) (7, 8)
> 8 9 (4, 5, 6, 7, 8) (7, 8)
> rows (ordered): 8
> rows: 8
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY ID RANGE BETWEEN CURRENT ROW AND 1 PRECEDING) FROM TEST;
> exception SYNTAX_ERROR_1
......@@ -415,7 +415,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 2 PRECEDING AND 1 PRE
> 6 3 (1, 2, 3, 4)
> 7 4 (3, 4, 5, 6)
> 8 4 (3, 4, 5, 6)
> rows (ordered): 8
> rows: 8
SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) FROM TEST;
> ID VALUE ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING)
......@@ -428,7 +428,7 @@ SELECT *, ARRAY_AGG(ID) OVER (ORDER BY VALUE RANGE BETWEEN 1 FOLLOWING AND 2 FOL
> 6 3 (7, 8)
> 7 4 null
> 8 4 null
> rows (ordered): 8
> rows: 8
DROP TABLE TEST;
> ok
......@@ -60,7 +60,7 @@ SELECT COUNT(ID) OVER (ORDER BY NAME) AS NR,
> -- --
> 1 3
> 2 1
> rows (ordered): 2
> rows: 2
SELECT NR FROM (SELECT COUNT(ID) OVER (ORDER BY NAME) AS NR,
A.ID AS ID FROM (SELECT ID, NAME FROM TEST ORDER BY NAME) AS A)
......@@ -82,7 +82,7 @@ SELECT I, V, COUNT(V) OVER W C, COUNT(DISTINCT V) OVER W D FROM
> 5 2 5 2
> 6 2 6 2
> 7 3 7 3
> rows (ordered): 7
> rows: 7
SELECT I, C, COUNT(I) OVER (PARTITION BY C) CNT FROM
VALUES (1, 1), (2, 1), (3, 2), (4, 2), (5, 2) T(I, C);
......
......@@ -17,7 +17,7 @@ select group_concat(v order by v asc separator '-'),
> GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4'))
> ---------------------------------------- -----------------------------------------------------------------------
> 2-3-4-5-6-7-8-9 9-8-7-6-5-4
> rows (ordered): 1
> rows: 1
create index test_idx on test(v);
> ok
......@@ -28,7 +28,7 @@ select group_concat(v order by v asc separator '-'),
> GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4'))
> ---------------------------------------- -----------------------------------------------------------------------
> 2-3-4-5-6-7-8-9 9-8-7-6-5-4
> rows (ordered): 1
> rows: 1
select group_concat(v order by v asc separator '-'),
group_concat(v order by v desc separator '-') filter (where v >= '4')
......@@ -36,7 +36,7 @@ select group_concat(v order by v asc separator '-'),
> GROUP_CONCAT(V ORDER BY V SEPARATOR '-') GROUP_CONCAT(V ORDER BY V DESC SEPARATOR '-') FILTER (WHERE (V >= '4'))
> ---------------------------------------- -----------------------------------------------------------------------
> 1-2-3-4-5-6-7-8-9 9-8-7-6-5-4
> rows (ordered): 1
> rows: 1
drop table test;
> ok
......@@ -63,7 +63,7 @@ select group_concat(distinct v order by v desc) from test;
> GROUP_CONCAT(DISTINCT V ORDER BY V DESC)
> ----------------------------------------
> 9,8,7,3,2,-1
> rows (ordered): 1
> rows: 1
drop table test;
> ok
......@@ -80,7 +80,7 @@ SELECT
> 6 21 21 21 36
> 7 28 28 15 36
> 8 36 36 8 36
> rows (ordered): 8
> rows: 8
SELECT I, V, SUM(V) OVER W S, SUM(DISTINCT V) OVER W D FROM
VALUES (1, 1), (2, 1), (3, 1), (4, 1), (5, 2), (6, 2), (7, 3) T(I, V)
......@@ -94,4 +94,4 @@ SELECT I, V, SUM(V) OVER W S, SUM(DISTINCT V) OVER W D FROM
> 5 2 6 3
> 6 2 8 3
> 7 3 11 6
> rows (ordered): 7
> rows: 7
......@@ -37,7 +37,7 @@ SELECT *,
> 7 22 33 33 33 21 21 21
> 8 33 null null null 22 22 22
> 9 null null null null 33 33 33
> rows (ordered): 9
> rows: 9
SELECT *,
LEAD(VALUE, 1) OVER (ORDER BY ID) LD,
......@@ -58,7 +58,7 @@ SELECT *,
> 7 22 33 33 33 21 21 21
> 8 33 null null null 22 22 22
> 9 null null null null 33 33 33
> rows (ordered): 9
> rows: 9
SELECT *,
LEAD(VALUE, 0) OVER (ORDER BY ID) LD,
......@@ -79,7 +79,7 @@ SELECT *,
> 7 22 22 22 22 22 22 22
> 8 33 33 33 33 33 33 33
> 9 null null null null null null null
> rows (ordered): 9
> rows: 9
SELECT *,
LEAD(VALUE, 2) OVER (ORDER BY ID) LD,
......@@ -100,7 +100,7 @@ SELECT *,
> 7 22 null null null null null 13
> 8 33 null null null 21 21 21
> 9 null null null null 22 22 22
> rows (ordered): 9
> rows: 9
SELECT *,
LEAD(VALUE, 2, 1111.0) OVER (ORDER BY ID) LD,
......@@ -121,7 +121,7 @@ SELECT *,
> 7 22 null null 1111 null null 13
> 8 33 1111 1111 1111 21 21 21
> 9 null 1111 1111 1111 22 22 22
> rows (ordered): 9
> rows: 9
SELECT LEAD(VALUE, -1) OVER (ORDER BY ID) FROM TEST;
> exception INVALID_VALUE_2
......@@ -144,7 +144,7 @@ SELECT LAG(VALUE) OVER (ORDER BY ID RANGE CURRENT ROW) FROM TEST;
DROP TABLE TEST;
> ok
SELECT C, SUM(I) S, LEAD(SUM(I)) OVER (ORDER /**/ BY SUM(I)) L FROM
SELECT C, SUM(I) S, LEAD(SUM(I)) OVER (ORDER BY SUM(I)) L FROM
VALUES (1, 1), (2, 1), (4, 2), (8, 2) T(I, C) GROUP BY C;
> C S L
> - -- ----
......
......@@ -44,7 +44,7 @@ SELECT *,
> 4 1 13 null null 12 13 13 13
> 5 1 null null null 12 null null 13
> 6 1 13 null null 12 13 13 13
> rows (ordered): 6
> rows: 6
SELECT *,
FIRST_VALUE(VALUE) OVER (ORDER BY ID) FIRST,
......@@ -59,7 +59,7 @@ SELECT *,
> 2 1 12 12 12 12 12 12 12
> 3 1 null 12 12 12 null null 12
> 4 1 13 12 12 12 13 13 13
> rows (ordered): 3
> rows: 3
SELECT *,
NTH_VALUE(VALUE, 2) OVER (ORDER BY ID) NTH,
......@@ -80,7 +80,7 @@ SELECT *,
> 4 1 13 12 12 null 12 12 null 13 13 12
> 5 1 null 12 12 13 12 12 13 13 13 12
> 6 1 13 12 12 null 12 12 null 13 13 13
> rows (ordered): 6
> rows: 6
SELECT *,
NTH_VALUE(VALUE, 2) OVER(ORDER BY ID) F,
......@@ -92,7 +92,7 @@ SELECT *,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) L_U_C,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) L_C_U,
NTH_VALUE(VALUE, 2) FROM LAST OVER(ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) L_U_U
FROM TEST;
FROM TEST ORDER BY ID;
> ID CATEGORY VALUE F F_U_C F_C_U F_U_U L L_U_C L_C_U L_U_U
> -- -------- ----- ---- ----- ----- ----- ---- ----- ----- -----
> 1 1 null null null 12 12 null null 41 41
......@@ -117,7 +117,7 @@ SELECT *,
FIRST_VALUE(VALUE) OVER (PARTITION BY CATEGORY ORDER BY ID) FIRST,
LAST_VALUE(VALUE) OVER (PARTITION BY CATEGORY ORDER BY ID) LAST,
NTH_VALUE(VALUE, 2) OVER (PARTITION BY CATEGORY ORDER BY ID) NTH
FROM TEST;
FROM TEST ORDER BY ID;
> ID CATEGORY VALUE FIRST LAST NTH
> -- -------- ----- ----- ---- ----
> 1 1 null null null null
......@@ -144,7 +144,7 @@ SELECT ID, CATEGORY,
> 1 1 null null
> 2 1 1 null
> 3 1 1 1
> rows (ordered): 3
> rows: 3
DROP TABLE TEST;
> ok
......@@ -17,16 +17,16 @@ SELECT NTILE(1) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2));
> --------------------------
> 1
> 1
> rows (ordered): 2
> rows: 2
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2));
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 2)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X)
> --------------------------
> 1
> 2
> rows (ordered): 2
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3));
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X)
> --------------------------
> 1
......@@ -34,7 +34,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3));
> 2
> rows (ordered): 3
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4));
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X)
> --------------------------
> 1
......@@ -43,7 +43,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 4));
> 2
> rows (ordered): 4
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5));
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X)
> --------------------------
> 1
......@@ -53,7 +53,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 5));
> 2
> rows (ordered): 5
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6));
SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)) ORDER BY X;
> NTILE(2) OVER (ORDER BY X)
> --------------------------
> 1
......@@ -64,7 +64,7 @@ SELECT NTILE(2) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6));
> 2
> rows (ordered): 6
SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3));
SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3)) ORDER BY X;
> NTILE(10) OVER (ORDER BY X)
> ---------------------------
> 1
......@@ -72,7 +72,7 @@ SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 3));
> 3
> rows (ordered): 3
SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22));
SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22)) ORDER BY X;
> NTILE(10) OVER (ORDER BY X)
> ---------------------------
> 1
......@@ -102,7 +102,7 @@ SELECT NTILE(10) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 22));
SELECT NTILE(0) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 1));
> exception INVALID_VALUE_2
SELECT NTILE(X) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6));
SELECT NTILE(X) OVER (ORDER BY X) FROM (SELECT * FROM SYSTEM_RANGE(1, 6)) ORDER BY X;
> NTILE(X) OVER (ORDER BY X)
> --------------------------
> 1
......
......@@ -41,7 +41,7 @@ SELECT *,
> 7 3 32 7 0.0 1.0 7 7 7 0.75 0.78
> 8 3 33 8 0.0 1.0 8 8 8 0.88 0.89
> 9 4 41 9 0.0 1.0 9 9 9 1.0 1.0
> rows (ordered): 9
> rows: 9
SELECT *,
ROW_NUMBER() OVER (ORDER BY CATEGORY) RN,
......@@ -61,7 +61,7 @@ SELECT *,
> 7 3 32 7 6 3 0.63 0.89
> 8 3 33 8 6 3 0.63 0.89
> 9 4 41 9 9 4 1.0 1.0
> rows (ordered): 9
> rows: 9
SELECT *,
ROW_NUMBER() OVER (PARTITION BY CATEGORY ORDER BY ID) RN,
......@@ -81,7 +81,7 @@ SELECT *,
> 7 3 32 2 2 2 0.5 0.67
> 8 3 33 3 3 3 1.0 1.0
> 9 4 41 1 1 1 0.0 1.0
> rows (ordered): 9
> rows: 9
SELECT
ROW_NUMBER() OVER (ORDER BY CATEGORY) RN,
......@@ -133,7 +133,7 @@ INSERT INTO TEST VALUES
(4, 'b', 8);
> update count: 4
SELECT ROW_NUMBER() OVER (ORDER /**/ BY TYPE) RN, TYPE, SUM(CNT) SUM FROM TEST GROUP BY TYPE;
SELECT ROW_NUMBER() OVER (ORDER BY TYPE) RN, TYPE, SUM(CNT) SUM FROM TEST GROUP BY TYPE;
> RN TYPE SUM
> -- ---- ---
> 1 a 1
......
......@@ -10,7 +10,7 @@ select * from test where id in (select id from test order by 'x');
> ID
> --
> 1
> rows (ordered): 1
> rows: 1
drop table test;
> ok
......@@ -63,7 +63,7 @@ AND studentID = 2;
> SUM(POINTS)
> -----------
> 30
> rows (ordered): 1
> rows: 1
SELECT eventID X FROM RESULTS
WHERE studentID = 2
......@@ -85,7 +85,7 @@ AND studentID = 2;
> SUM(R.POINTS)
> -------------
> 30
> rows (ordered): 1
> rows: 1
drop table results;
> ok
......@@ -97,7 +97,7 @@ create table test(id int, name varchar) as select 1, 'a';
> ID
> --
> 1
> rows (ordered): 1
> rows: 1
drop table test;
> ok
......@@ -162,7 +162,7 @@ select id from test where name in(null, null);
select * from (select * from test order by name limit 1) where id < 10;
> ID NAME
> -- ----
> rows (ordered): 0
> rows: 0
drop table test;
> ok
......@@ -335,7 +335,7 @@ select * from dual where x in (select x from dual group by x order by max(x));
> X
> -
> 1
> rows (ordered): 1
> rows: 1
create table test(d decimal(1, 2));
> exception INVALID_VALUE_SCALE_PRECISION
......@@ -742,7 +742,7 @@ select * from(select 1 from system_range(1, 2) group by sin(x) order by sin(x));
> -
> 1
> 1
> rows (ordered): 2
> rows: 2
create table parent as select 1 id, 2 x;
> ok
......@@ -1190,7 +1190,7 @@ drop table p;
> X
> -
> 1
> rows (ordered): 1
> rows: 1
create table test(a int, b int default 1);
> ok
......@@ -2813,7 +2813,7 @@ select rownum, * from (select * from test where id>1 order by id desc);
> -------- -- ----
> 1 3 33
> 2 2 22
> rows (ordered): 2
> rows: 2
update test set name='x' where rownum<2;
> update count: 1
......@@ -3289,7 +3289,7 @@ select select a from test order by id;
> SELECT A FROM PUBLIC.TEST /* PUBLIC.PRIMARY_KEY_2 */ /* scanCount: 2 */ ORDER BY =ID /* index sorted */
> -------------------------------------------------------------------------------------------------------
> TRUE
> rows (ordered): 1
> rows: 1
insert into test values(2, 'N');
> update count: 1
......@@ -6676,7 +6676,7 @@ SELECT GROUP_CONCAT(ID ORDER BY ID) FROM TEST;
> GROUP_CONCAT(ID ORDER BY ID)
> ----------------------------
> 1,2,3,4,5,6,7,8,9
> rows (ordered): 1
> rows: 1
SELECT STRING_AGG(ID,';') FROM TEST;
> GROUP_CONCAT(ID SEPARATOR ';')
......@@ -7945,9 +7945,9 @@ insert into test values (2014, 'execution'), (2015, 'execution'), (2016, 'execut
select * from test where year in (select distinct year from test order by year desc limit 1 offset 0);
> YEAR ACTION
> ---- ---------
> 2016 order
> 2016 execution
> rows (ordered): 2
> 2016 order
> rows: 2
drop table test;
> ok
......
......@@ -27,7 +27,7 @@ SELECT *, ROW_NUMBER() OVER W1, ROW_NUMBER() OVER W2 FROM TEST
> 2 3 1 2 1
> 3 2 2 1 2
> 4 1 2 2 1
> rows (ordered): 4
> rows: 4
SELECT *, LAST_VALUE(ID) OVER W FROM TEST
WINDOW W AS (PARTITION BY CATEGORY ORDER BY ID RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW);
......@@ -37,7 +37,7 @@ SELECT *, LAST_VALUE(ID) OVER W FROM TEST
> 2 3 1 1
> 3 2 2 4
> 4 1 2 3
> rows (ordered): 4
> rows: 4
DROP TABLE TEST;
> ok
......@@ -75,7 +75,7 @@ SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY C
> 1 12
> rows: 1
SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY > 1;
SELECT ROW_NUMBER() OVER (ORDER BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY > 1;
> ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID)
> ------------------------------------- -------
> 1 12
......@@ -97,13 +97,13 @@ INSERT INTO TEST VALUES
(32, FALSE);
> update count: 6
SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING SUM(ID) = 12;
SELECT ROW_NUMBER() OVER (ORDER BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING SUM(ID) = 12;
> ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID)
> ------------------------------------- -------
> 1 12
> rows: 1
SELECT ROW_NUMBER() OVER (ORDER /**/ BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY;
SELECT ROW_NUMBER() OVER (ORDER BY CATEGORY), SUM(ID) FROM TEST GROUP BY CATEGORY HAVING CATEGORY;
> ROW_NUMBER() OVER (ORDER BY CATEGORY) SUM(ID)
> ------------------------------------- -------
> 1 12
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论