mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-19 04:03:06 +08:00
This changes the license text for SQL files to be identical with the license text for C files.
95 lines
2.4 KiB
Plaintext
95 lines
2.4 KiB
Plaintext
-- This file and its contents are licensed under the Apache License 2.0.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-APACHE for a copy of the license.
|
|
-- table 1
|
|
CREATE TABLE "hitest1"(key real, val varchar(40));
|
|
-- insertions
|
|
INSERT INTO "hitest1" VALUES(0, 'hi');
|
|
INSERT INTO "hitest1" VALUES(1, 'sup');
|
|
INSERT INTO "hitest1" VALUES(2, 'hello');
|
|
INSERT INTO "hitest1" VALUES(3, 'yo');
|
|
INSERT INTO "hitest1" VALUES(4, 'howdy');
|
|
INSERT INTO "hitest1" VALUES(5, 'hola');
|
|
INSERT INTO "hitest1" VALUES(6, 'ya');
|
|
INSERT INTO "hitest1" VALUES(1, 'sup');
|
|
INSERT INTO "hitest1" VALUES(2, 'hello');
|
|
INSERT INTO "hitest1" VALUES(1, 'sup');
|
|
-- table 2
|
|
CREATE TABLE "hitest2"(name varchar(30), score integer, qualify boolean);
|
|
-- insertions
|
|
INSERT INTO "hitest2" VALUES('Tom', 6, TRUE);
|
|
INSERT INTO "hitest2" VALUES('Mary', 4, FALSE);
|
|
INSERT INTO "hitest2" VALUES('Jaq', 3, FALSE);
|
|
INSERT INTO "hitest2" VALUES('Jane', 10, TRUE);
|
|
-- standard 2 bucket
|
|
SELECT histogram(key, 0, 9, 2) FROM hitest1;
|
|
histogram
|
|
-----------
|
|
{0,8,2,0}
|
|
(1 row)
|
|
|
|
-- standard multi-bucket
|
|
SELECT histogram(key, 0, 9, 5) FROM hitest1;
|
|
histogram
|
|
-----------------
|
|
{0,4,3,2,1,0,0}
|
|
(1 row)
|
|
|
|
-- standard 3 bucket
|
|
SELECT val, histogram(key, 0, 7, 3) FROM hitest1 GROUP BY val ORDER BY val;
|
|
val | histogram
|
|
-------+-------------
|
|
hello | {0,2,0,0,0}
|
|
hi | {0,1,0,0,0}
|
|
hola | {0,0,0,1,0}
|
|
howdy | {0,0,1,0,0}
|
|
sup | {0,3,0,0,0}
|
|
ya | {0,0,0,1,0}
|
|
yo | {0,0,1,0,0}
|
|
(7 rows)
|
|
|
|
-- standard element beneath lb
|
|
SELECT histogram(key, 1, 7, 3) FROM hitest1;
|
|
histogram
|
|
-------------
|
|
{1,5,2,2,0}
|
|
(1 row)
|
|
|
|
-- standard element above ub
|
|
SELECT histogram(key, 0, 3, 3) FROM hitest1;
|
|
histogram
|
|
-------------
|
|
{0,1,3,2,4}
|
|
(1 row)
|
|
|
|
-- standard element beneath and above lb and ub, respectively
|
|
SELECT histogram(key, 1, 3, 2) FROM hitest1;
|
|
histogram
|
|
-----------
|
|
{1,3,2,4}
|
|
(1 row)
|
|
|
|
-- standard 1 bucket
|
|
SELECT histogram(key, 1, 3, 1) FROM hitest1;
|
|
histogram
|
|
-----------
|
|
{1,5,4}
|
|
(1 row)
|
|
|
|
-- standard 2 bucket
|
|
SELECT qualify, histogram(score, 0, 10, 2) FROM hitest2 GROUP BY qualify;
|
|
qualify | histogram
|
|
---------+-----------
|
|
f | {0,2,0,0}
|
|
t | {0,0,1,1}
|
|
(2 rows)
|
|
|
|
-- standard multi-bucket
|
|
SELECT qualify, histogram(score, 0, 10, 5) FROM hitest2 GROUP BY qualify
|
|
qualify | histogram
|
|
---------+-----------------
|
|
f | {0,0,1,1,0,0,0}
|
|
t | {0,0,0,0,1,0,1}
|
|
(2 rows)
|
|
|