Anton wrote:
>> SELECT login_id, MAX(collect_time) AS most_recent
>> FROM n_traffic
>> GROUP BY login_id
>> ORDER BY login_id DESC, collect_time DESC
> is not so good:
> =# SELECT login_id, MAX(collect_time) AS most_recent
> -# FROM n_traffic
> -# GROUP BY login_id
> -# ORDER BY login_id DESC, collect_time DESC;
> ERROR: column "n_traffic.collect_time" must appear in the GROUP BY
> clause or be used in an aggregate function
>
> If I correct this error (add collect time to GROUP BY) I'll just get
> full table, sorted. And I tried to not use aggregate functions because
> they make to do full table scan...
Sorry - my typo. The order-by doesn't need "collect_time" of course.
--
Richard Huxton
Archonet Ltd