Files
greptimedb/tests/cases/standalone/order/order_by.sql
dennis zhuang 9428e70971 feat: integration test (#770)
* feat: add insert test cases

* fix: update results after rebase develop

* feat: supports unsigned integer types and big_insert test

* test: add insert_invalid test

* feat: supports time index constraint for bigint type

* chore: time index column at last

* test: adds more order, limit test

* fix: style

* feat: adds numbers table in standable memory catalog mode

* feat: enable fail_fast and test_filter in sqlness

* feat: add more tests

* fix: test_filter

* test: add alter tests

* feat: supports if_not_exists when create database

* test: filter_push_down and catalog test

* fix: compile error

* fix: delete output file

* chore: ignore integration test output in git

* test: update all integration test results

* fix: by code review

* chore: revert .gitignore

* feat: sort the show tables/databases results

* chore: remove issue link

* fix: compile error and code format after rebase

* test: update all integration test results
2023-01-10 18:15:50 +08:00

59 lines
1.7 KiB
SQL

CREATE TABLE test (a BIGINT, b INTEGER, time index(a));
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
select b from test where a = 12;
SELECT b FROM test ORDER BY a DESC;
SELECT a, b FROM test ORDER BY a;
SELECT a, b FROM test ORDER BY a DESC;
SELECT a, b FROM test ORDER BY b, a;
SELECT a, b FROM test ORDER BY 2, 1;
SELECT a, b FROM test ORDER BY b DESC, a;
SELECT a, b FROM test ORDER BY b, a DESC;
SELECT a, b FROM test ORDER BY b, a DESC LIMIT 1;
SELECT a, b FROM test ORDER BY b, a DESC LIMIT 1 OFFSET 1;
SELECT a, b FROM test ORDER BY b, a DESC OFFSET 1;
SELECT a, b FROM test WHERE a < 13 ORDER BY b;
SELECT a, b FROM test WHERE a < 13 ORDER BY 2;
SELECT a, b FROM test WHERE a < 13 ORDER BY b DESC;
SELECT b, a FROM test WHERE a < 13 ORDER BY b DESC;
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY b % 2;
SELECT b % 2 AS f, a FROM test ORDER BY b % 2, a;
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY f;
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY 1;
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY k;
-- ORDER BY on alias in right-most query
-- CONTROVERSIAL: SQLite allows both "k" and "l" to be referenced here, Postgres and MonetDB give an error.
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY l;
-- Not compatible with duckdb, work in gretimedb
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY 1-k;
-- Not compatible with duckdb, give an error in greptimedb
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY a-10;
-- Not compatible with duckdb, give an error in greptimedb
SELECT a-10 AS k FROM test UNION SELECT a-11 AS l FROM test ORDER BY a-11;
DROP TABLE test;