compID OrderId rate __________________________________________ 15 123 1000 12 123 2344 13 123 2456 14 123 2666 119 234 3245 120 234 3678 118 234 4566 23 234 6789 22 345 900 27 345 980 26 345 1567 25 345 1600
select orderid,compid from TableName where rate in(select MIN(rate) from TableName group by OrderId)
SELECT compID, OrderId, rate FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY OrderId ORDER BY rate) AS rn FROM TestTable ) AS T1 WHERE rn = 1
select compID ,OrderId , MIN(rate) from TableName GROUP BY compID ,OrderId
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)