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
firstname | surname | count |
---|
SELECT 0
ERROR: column "test.firstname" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: select firstname, surname, count(*) ^
id | id2 | firstname | surname |
---|---|---|---|
1 | 1 | f1 | s1 |
2 | 2 | f1 | s1 |
INSERT 0 2
firstname | surname | count |
---|---|---|
f1 | s1 | 1 |
f1 | s1 | 1 |
SELECT 2
ERROR: column "test.firstname" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: select firstname, surname, count(*) ^
CREATE TABLE
id | fk | other_info |
---|---|---|
1 | 1 | other_info_1_1 |
2 | 1 | other_info_1_2 |
3 | 2 | other_info_2_3 |
INSERT 0 3
firstname | surname | count |
---|---|---|
f1 | s1 | 1 |
f1 | s1 | 2 |
SELECT 2
ERROR: column "test2.other_info" must appear in the GROUP BY clause or be used in an aggregate function LINE 2: other_info, --that's from another table, so it won't ... ^