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
Originally Posted on October 10, 2013
Last Updated on October 26, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.