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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-12 : 09:10:05
|
| David writes "I am searching through a table that may have duplicate names. I am using a group by on 4 fields. I need to include a unique id along with the list of duplicates. How do I join this unique id that belongs to the name of the potential duplicates within the group by SQL statement? Code: select NameInformation_Individuals.lastname, NameInformation_Individuals.firstname,Disease.name,Patient_Case.MMWRYear, Patient_Case.Age, count(*)from Disease INNER JOIN Patient_Case ON Disease.id = Patient_Case.disease_id INNER JOIN NameInformation_Individuals ON Patient_Case.NameID = NameInformation_Individuals.NameIDWHERE Patient_Case.MMWRYear = 2001group by NameInformation_Individuals.lastname, NameInformation_Individuals.firstname,Disease.name, Patient_Case.MMWRYear, Patient_Case.Agehaving count(*) > 1order by count(*) desc, NameInformation_Individuals.lastname, NameInformation_Individuals.firstname" |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
|
|
|
|
|