SELECT n.*, count(c.cnid) AS nc FROM sfn_news AS n LEFT JOIN sfn_comments AS c ON (c.cnid = n.nid) GROUP BY n.nid ORDER BY n.nid DESC; -- ERROR: column "n.ndate" must appear in the GROUP BY clause or be used in an aggregate function
SELECT n.*, count(c.cnid) AS nc FROM sfn_news AS n LEFT JOIN sfn_comments AS c ON (c.cnid = n.nid) GROUP BY n.nid, n.ndate, n.nuser, n.nsubject, n.ncontents ORDER BY n.nid DESC; -- OK - tylko dużo pisania, poprostu chciałbym krótrzy zapis o ile jest to możliwe
SELECT n.*, count(c.cnid) AS nc FROM sfn_news AS n LEFT JOIN sfn_comments AS c ON (c.cnid = n.nid) GROUP BY n.* ORDER BY n.nid DESC; -- ERROR: relation reference "n" cannot be used as a select-list entry -- HINT: Write "n".* to denote all the columns of the relation.
No i nie bardzo rozumiem tą wskazówkę
