I have a postgresql function with 'GROUP BY' which works fine on my local server (postgresql version is 12.6) but gets the famous error 'column "f.fa_docnum" must appear in the GROUP BY clause or be used in an aggregate function' on the web server, which runs postgresql 9.2.24. I'm completely confused about that. The documentation of the 2 versions are exactly the same for the GROUP BY clause.
Here is the function (a bit simpler than the original one, but it gets the same results) :
SELECT
f.fa_docnum,
f.fa_date,
sum(l.lj_credit),
sum(l.lj_debit)
FROM livrejournal l, document d, facture_achat f
WHERE d.doc_id = l.lj_docid
AND d.doc_fa_docnum = f.fa_docnum
AND f.fa_fournisseur = 59
GROUP BY (f.fa_docnum, f.fa_date);
On the production site with 9.2 version, I get no error if I delete 'f.fa_date' column in the GROUP BY clause, while on the local dev site with 12.6 (and formerly lower versions) I get no error in any case. If anybody has an idea about this strange behavior, and maybe some tip or workaround, I would greatly appreciate it.