> 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