Skip to content

Instantly share code, notes, and snippets.

@dankleiman
Created September 27, 2019 19:28
Show Gist options
  • Save dankleiman/297dc0198691b781974ae8e81e40b20c to your computer and use it in GitHub Desktop.
Save dankleiman/297dc0198691b781974ae8e81e40b20c to your computer and use it in GitHub Desktop.
Data set up script for dankleiman.com/2019/09/27/sql-quick-tip-showing-changes-in-your-data/
CREATE TABLE daily_metrics AS (
SELECT date, metric, count FROM (SELECT '2019-09-01', 'A', 115) as r(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-02', 'A', 98) as r2(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-03', 'A', 268) as r2(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-04', 'A', 451) as r4(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-05', 'A', 239) as r5(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-06', 'A', 75) as r6(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-07', 'A', 306) as r7(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-01', 'B', 38) as r8(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-02', 'B', 14) as r9(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-03', 'B', 77) as r10(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-04', 'B', 203) as r11(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-05', 'B', 251) as r12(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-06', 'B', 300) as r13(date, metric, count)
UNION
SELECT date, metric, count FROM (SELECT '2019-09-07', 'B', 165) as r14(date, metric, count)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment