add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
CREATE TABLE
INSERT 0 8
purchase_date customer_id
2015-05-25 03:24:09 15
2015-06-21 06:33:35 15
2015-07-02 02:03:32 17
2015-07-25 10:20:31 15
2015-07-25 10:20:31 12
2015-07-26 01:20:31 17
2015-08-26 03:24:09 17
2015-08-21 03:21:21 14
SELECT 8
month customer_id
2015-07-01 00:00:00 17
2015-08-01 00:00:00 17
2015-05-01 00:00:00 15
2015-06-01 00:00:00 15
2015-07-01 00:00:00 15
2015-08-01 00:00:00 14
2015-07-01 00:00:00 12
SELECT 7
month customer_id first_value count
2015-07-01 00:00:00 12 2015-07-01 00:00:00 1
2015-08-01 00:00:00 14 2015-08-01 00:00:00 1
2015-05-01 00:00:00 15 2015-05-01 00:00:00 1
2015-06-01 00:00:00 15 2015-05-01 00:00:00 2
2015-07-01 00:00:00 15 2015-05-01 00:00:00 3
2015-07-01 00:00:00 17 2015-07-01 00:00:00 1
2015-08-01 00:00:00 17 2015-07-01 00:00:00 2
SELECT 7
month customer_id months count
2015-07-01 00:00:00 12 00:00:00 1
2015-08-01 00:00:00 14 00:00:00 1
2015-05-01 00:00:00 15 00:00:00 1
2015-06-01 00:00:00 15 1 mon 2
2015-07-01 00:00:00 15 2 mons 3
2015-07-01 00:00:00 17 00:00:00 1
2015-08-01 00:00:00 17 1 mon 2
SELECT 7
customer_id
15
SELECT 1