Re: Formatting a month in query output
От
Alexander Borkowski
Тема
Re: Formatting a month in query output
Дата
Msg-id
41F82962.8070908@abri.une.edu.au
Ответ на
Re: Formatting a month in query output (Rodolfo J. Paiz)
Список
Дерево обсуждения
Formatting a month in query output "Rodolfo J. Paiz" <rpaiz@simpaticus.com>
Re: Formatting a month in query output Alexander Borkowski <alexander.borkowski@abri.une.edu.au>
> flightlog=> select to_char(date,'Mon YYYY') as month, count(num) as num, > sum(hrs_total) as hours from flights group by month order by date asc; > > ERROR: column "flights.date" must appear in the GROUP BY clause or be > used in an aggregate function Try this: select to_char(date,'Mon YYYY') as month, count(num) as num, sum(hrs_total) as hours from flights group by date, month order by date asc; > Using "order by date" > gets me an error since the date column is not used in the query. It is (for sorting). "date" is just not grouped and you can't do this, which is what the above error message is all about: you have group it or use an aggregate function (e.g. count, sum, ...) on it as you do for all other columns in that query. Cheers, Alex
В списке pgsql-novice по дате отправления