I am trying to select items from a file and to group on the CCYY-MM part of
the date, in order to give a total count of items for that period
SELECT
SUBSTRING(mylog.datetime,1,7) AS datetime,
count(*) as counter
FROM mylog
WHERE mylog.datetime<'2005-02-02'
GROUP BY SUBSTRING(mylog.datetime,1,7)
ORDER BY mylog.datetime;
However I get the error message
ERROR: column "mylog.datetime" must appear in the GROUP BY clause or be
used in an aggregate function
I have also used date_trunc('month', mylog.datetime) with the same error
Help!!!!