If I issue a query like this:
select c1, c2, c3
from table
group by c1;
i get distinct results for c1, but how do i sort it (e.g. c2 descending) before the group by?
select c1, c2, c3
from (select c1, c2, c3 from table order by c2 desc) t
group by c1;
Your question is unclear, but if you need got higher value of c2 for each c1 you may use Max
select c1, Max(c2), Max(c3)
from table
group by c1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With