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?.
SELECT 7
ERROR: DISTINCT is not implemented for window functions LINE 4: count(distinct itemid) over (order by date) as ... ^
id | itemid | date | data | min_id | cnt_itemid |
---|---|---|---|---|---|
1 | 1000 | 2000-10-12 | a | 1 | 1 |
2 | 1000 | 2000-10-12 | b | 1 | 1 |
3 | 1002 | 2000-09-12 | c | 3 | 2 |
4 | 1001 | 2000-07-12 | d | 4 | 3 |
5 | 1000 | 2000-05-12 | e | 1 | 3 |
SELECT 5
id | itemid | date | data | min_id | cnt_itemid | min_cnt_itemid_3 |
---|---|---|---|---|---|---|
1 | 1000 | 2000-10-12 | a | 1 | 1 | 4 |
2 | 1000 | 2000-10-12 | b | 1 | 1 | 4 |
3 | 1002 | 2000-09-12 | c | 3 | 2 | 4 |
4 | 1001 | 2000-07-12 | d | 4 | 3 | 4 |
SELECT 4
id | itemid | date | data |
---|---|---|---|
1 | 1000 | 2000-10-12 | a |
2 | 1000 | 2000-10-12 | b |
3 | 1002 | 2000-09-12 | c |
4 | 1001 | 2000-07-12 | d |
SELECT 4
itemid | max |
---|---|
1000 | 2000-10-12 |
1002 | 2000-09-12 |
1001 | 2000-07-12 |
SELECT 3