I want to select distinct status
values odered by time
. However, my following query, which groups by status
and orders by time
, shows error like time
column must be added in group by.
The query I tried is:
select "status"
from detail_status
where "CAId" = 'test-1234'
group by "status"
order by "time" desc
limit 2;
If I add time colum in GROUP BY
then the result is in wrong order. I need the above query result just grouped by status
column.
Please, assist for this issue or give another idea for this query concept.
Thanks in adavance.