Click here to Skip to main content
15,945,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table with two columns statecode and state having values as-
Statecode state
1 DLI
2 MH
3 UP
2 DLI

In my output i need only those rows that do not have duplicate values in any of the column, I.e., O/p should be like

Statecode State
2 MH
3 UP
Posted

SELECT DISTINCT statecode, state FROM 'table'
 
Share this answer
 
Comments
Member 10221062 20-Aug-13 12:44pm    
I tried that too, but it will give me my output as
Statecode state
1 DLI
2 MH
3 UP

whereas i dont want 1 DLI in my output.. :(
get duplicates using
SQL
select state from statetable ,count(*)
group by state 
having count(*) > 1


then you can get rid of them using
SQL
select statecode, state from statetable 
where state not in ()
 
Share this answer
 
v4
Comments
Member 10221062 20-Aug-13 13:27pm    
Thnks for the help.. i will try this, hopefully this will work.. thnks once again.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900