2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS distinct;
|
|
|
|
CREATE TABLE distinct (Num UInt32, Name String) ENGINE = Memory;
|
2017-01-12 15:34:41 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
INSERT INTO distinct (Num, Name) VALUES (1, 'John');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (1, 'John');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (3, 'Mary');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (3, 'Mary');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (3, 'Mary');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (4, 'Mary');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (4, 'Mary');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (5, 'Bill');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (7, 'Bill');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (7, 'Bill');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (7, 'Mary');
|
|
|
|
INSERT INTO distinct (Num, Name) VALUES (7, 'John');
|
2017-01-12 15:34:41 +00:00
|
|
|
|
2022-07-30 20:36:27 +00:00
|
|
|
-- { echoOn }
|
2017-01-12 15:34:41 +00:00
|
|
|
-- String field
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT Name FROM (SELECT DISTINCT Name FROM distinct) ORDER BY Name;
|
2017-01-12 15:34:41 +00:00
|
|
|
-- Num field
|
2019-04-16 14:13:13 +00:00
|
|
|
SELECT Num FROM (SELECT DISTINCT Num FROM distinct) ORDER BY Num;
|
2022-07-30 20:36:27 +00:00
|
|
|
-- all const columns
|
|
|
|
SELECT DISTINCT 1 as a, 2 as b FROM distinct;
|
|
|
|
-- { echoOff }
|
2017-01-12 15:34:41 +00:00
|
|
|
|
2019-04-16 14:13:13 +00:00
|
|
|
DROP TABLE IF EXISTS distinct;
|