Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2007-12-18 : 11:23:24
|
| I have a table of names in which some names are repeted. I need to count the number of unique names. DISTINCT will return the unique rows. Now I need to count them. I think I am on the right track but can't get the syntex right. Where am i going wrong?select count(*) from Names where (select distinct First_Name, Last_Name from Names) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-18 : 11:25:43
|
| Try thisselect COUNT(DISTINCT First_Name,Last_Name) from Names |
 |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2007-12-18 : 11:28:54
|
| Statement :select COUNT(DISTINCT First_Name,Last_Name) from Namesreturns this error:Msg 102, Level 15, State 1, Line 1Incorrect syntax near ','. |
 |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2007-12-18 : 11:38:56
|
| This seems to work:select COUNT(DISTINCT First_Name + Last_Name) from NamesThanks. You got me looking in the right place for the solution. |
 |
|
|
|
|
|