I need some help in SQL Server
I have a number of table rows like below.
ID Name status
1 viral/AHD Yes
2 viral/AHD No
3 joe/US Yes
4 thomas/IND Yes
5 jack/IND No
Now I want to select those rows which are distinct in Name column, that is the 3rd, 4th, 5th and those rows which are duplicate in Name but status is Yes..
So my final answer would be like this:
ID Name Status
1 viral/AHD Yes
3 joe/US Yes
4 thomas/IND Yes
5 jack/IND No
If you are using sql 2005+. Then this might help:
EDIT
Or even simpler. Like this:
Useful references: