name sold_price ram 2000 shyam 3000 ram 4000 hari 50000 Want: name sold_price ram 2000 shyam 3000 hari 50000
Show first reference of ram
SELECT name,sold_price FROM ( SELECT ID ,name ,sold_price ,ROW_NUMBER() OVER ( PARTITION BY name ORDER BY ID ) rn FROM shop ) a WHERE rn = 1
name sold_price hari 5000.00 ram 2000.00 shyam 3000.00
Show last reference of ram
SELECT name,sold_price FROM ( SELECT ID ,name ,sold_price ,ROW_NUMBER() OVER ( PARTITION BY name ORDER BY ID DESC ) rn FROM shop ) a WHERE rn = 1
name sold_price hari 5000.00 ram 4000.00 shyam 3000.00
Last Updated on October 26, 2015