Click here to Skip to main content
15,920,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to write a query to get state names from MASTER Table? Condition is like should not repeat same state. For example in master table there are 1000 records in that 100 records has State name 'KARNATAKA' and one more state 'KERALA' contains 100 records. So I want to get only state names which should not repeat? So Can any one help me to find this query?

This query is displaying all(1000) records
"Select StateName from MasterTable"

Thanks in @dV@nCe........:P
Posted

SQL
Select Distinct StateName from MasterTable


or


SQL
Select StateName from MasterTable group by statename
 
Share this answer
 
v2
Comments
Aboobakkar Siddeq D U 2-Aug-13 6:35am    
Thanks a lot
Adarsh chauhan 2-Aug-13 6:47am    
+5
simply add distinct keyword..


Select distinct StateName from MasterTable
 
Share this answer
 
Comments
Aboobakkar Siddeq D U 2-Aug-13 6:35am    
Thanks a lot
Adarsh chauhan 2-Aug-13 6:45am    
You are most welcome.. :)

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