I have the table named DealOffers :
I want to select only one record from each group of dealIds where Price is minimum.
i.e : the expected output should be like this:
I have the table named DealOffers :
I want to select only one record from each group of dealIds where Price is minimum.
i.e : the expected output should be like this:
 
    
    You can do something like this. However, you should consider performance if you end up having to do this on a massive scale.
select *
from (
    select *,
        SeqNum = row_number() over(
            partition by DealId
            order by Price)
    from DealOffers) do
where do.SeqNum = 1;
