Group by-Klausel in mySQL und postgreSQL, warum der Fehler in postgreSQL?

Angenommen, ich habe diese Tabelle: named =Der Tisc dessen Struktur ist:

postgreSQL:

 create table the_table (col3 SERIAL, col2 varchar, col1 varchar, PRIMARY KEY(col3));

MySQL:

create table the_table ( col3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, col2 varchar(20), col1 varchar(20) )

Dann habe ich die Tabelle eingefügt:

INSERT INTO the_table (col2,col1) VALUES 
('x','a'),
('x','b'),
('y','c'),
('y','d'),
('z','e'),
('z','f');

Nun sieht die Tabelle so aus:

col3 | col2 | col1 
------+------+------
    1 | x    | a
    2 | x    | b
    3 | y    | c
    4 | y    | d
    5 | z    | e
    6 | z    | f

Wenn ich diese Abfrage mache:

select * from the_table group by col2

then in MySQL bekomme ich:

1 x a
3 y c
5 z e

und in postgreSQL erhalte ich die Fehlermeldung:

ERROR:  column "the_table.col3" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: select * from the_table group by col2;

Meine Fragen

Was bedeutet dieser Fehler? Was ist eine Aggregatfunktion?

Wenn es in MySQL funktioniert, warum kann es in PostgreSQL nicht funktionieren?

Antworten auf die Frage(6)

Ihre Antwort auf die Frage