ID SKU Price 1 ABC1 200 2 ABC1 500 3 ABC1 0 4 XYZ 550 5 XYZ 100 6 LMN 600 7 LMN 300 8 LMN 10
ID SKU Price 3 ABC1 0 5 XYZ 100 8 LMN 10
SELECT t1.ID, t1.SKU, t1.Price FROM YourTable AS t1 RIGHT JOIN ( SELECT SKU, MAX(ID) AS ID FROM YourTable GROUP BY SKU ) AS t2 ON t1.ID = t2.ID ORDER BY ID
Select * from MyTable where ID in (select MAX(ID) from MyTable group by SKU)
JOIN
IN
select Id,SKU,Price from ( select Row_Number() over(partition by sku order by sku,price ) as sr,Id, SKU, Price from tblName ) as temp where sr = 1
price
ORDER BY
ROW_NUMBER
ROW_NUMBER() OVER(PARTITION BY SKU ORDER BY ID DESC)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)