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 |
TimeIsShort
Starting Member
2 Posts |
Posted - 2011-04-20 : 19:18:41
|
Good day all,My question pertains to a table similar to the one below. Consider an employee table with the following data (first row header) and no primary key:FirstName,LastName,Email,TelephoneJohn,Doe,j.doe@somewhere.com,9991231234J,Doe,j.doe@somewhere.com,9991231234Jonathan,Doe,j.doe@somewhere.com,9991231234Jane,Doe,jane.doe@somewhere.com,9993214321Given such a table, what is the correct SQL syntax (SQL Server 2000) that would return the first three row (i.e. disregards first name, and returns rows with duplicate last name AND email AND telephone)?Thank you to all in advance. |
|
singularity
Posting Yak Master
153 Posts |
Posted - 2011-04-20 : 19:42:02
|
[code]select *from employee awhere exists (select LastName, Email, Telephone from employee b where a.LastName = b.LastName and a.Email = b.Email and a.Telephone = b.Telephone group by LastName, Email, Telephone having count(*) > 1)[/code] |
|
|
TimeIsShort
Starting Member
2 Posts |
Posted - 2011-04-21 : 10:30:59
|
Thank you. Worked like a charm. |
|
|
Maqsood
Starting Member
1 Post |
Posted - 2012-10-09 : 04:21:39
|
Initial obsrvation is under way so I woukd like to suggest u please wait for sometimw.ThanksMuhammed Maqsood |Application Support Team Member (ASG)|TCSSpringboard BAM/EDW | EIP | AS&M |Service Infrastructure| BT OperatePlot B1, Block EP & GP, Sector - V, Salt Lake Electronics Complex, Kolkata - 700091 INDIAOffice : +91 33 - 66366197 | Mobile : +91 90383 48889Mailto: muhammed.alam@tcs.comWebsite: http://www.tcs.comExperience certainty. IT ServicesBusiness SolutionsOutsourcing |
|
|
|
|
|
|
|