Skip to content

Instantly share code, notes, and snippets.

@dcrystalj
Created March 26, 2022 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcrystalj/3bc15d64fa6d807d7131adac3417c6db to your computer and use it in GitHub Desktop.
Save dcrystalj/3bc15d64fa6d807d7131adac3417c6db to your computer and use it in GitHub Desktop.
CREATE SCHEMA subquery;
USE subquery;
CREATE TABLE IF NOT EXISTS "user" (
id INT,
name VARCHAR (50)
);
CREATE TABLE IF NOT EXISTS "location" (
id INT,
user_id INT,
name VARCHAR (50),
moved_on TIMESTAMP
);
INSERT INTO "user" VALUES
(1, 'tom'),
(2, 'sally'),
(3, 'ben');
INSERT INTO location VALUES
(1, 1, 'New York', TIMESTAMP '2010-1-1 00:00:00'),
(2, 1, 'Columbus', TIMESTAMP '2011-1-1 00:00:00'),
(3, 1, 'Miami', TIMESTAMP '2012-1-1 00:00:00'),
(4, 2, 'Miami', TIMESTAMP '2010-1-1 00:00:00'),
(5, 2, 'Columbus', TIMESTAMP '2011-1-1 00:00:00'),
(6, 3, 'Miami', TIMESTAMP '2010-1-1 00:00:00'),
(7, 3, 'New York', TIMESTAMP '2011-1-1 00:00:00');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment