View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 09:31 AM
Radoulov, Dimitre
 
Posts: n/a
Default Re: Order By and Group By

> I have a table below...
>
> c1 c2 c3
> 1 1 a
> 1 2 b
> 2 1 c
> 2 2 d
> 3 1 e
> 3 2 f
>
>
> I want to get (1,2,b), (2,2,d), (3,2,f), i.e. group by c1, which having
> the largest c2, and select the row

[...]

select * from t
group by c1,c2
having c2=(select max(c2) from t)
order by c1;



Regards
Dimitre


Reply With Quote