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 |
|
mikejohnson
Posting Yak Master
153 Posts |
Posted - 2004-01-28 : 11:20:26
|
| i want to show my users all the duplicates in the database. here is my query so far:SELECT SAP, PromoID, WeekEnding, COUNT(*) AS DuplicateCount, UnitsFROM UnitsGROUP BY SAP, PromoID, WeekEnding, UnitsHAVING (COUNT(*) > 1)the problem i have is right now it shows only one of the records contained within the duplicates. i want it to show all of them. for example, in my database i have these 3 records:sap promoid weekending units--- ------- ---------- -----1 1 1/1/03 11 1 1/1/03 1right now it only shows one record with that data, i need it to show both, how do i do that? |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2004-01-28 : 12:03:14
|
| How about:SELECT *FROM Units UJOIN ( SELECT SAP, PromoID, WeekEnding, Units, COUNT(*) AS DuplicateCount FROM Units GROUP BY SAP, PromoID, WeekEnding, Units HAVING (COUNT(*) > 1) ) as dON U.SAP = d.SAPAND U.PromoID = d.PromoID AND U.WeekEnding = d.WeekEndingAND U.Units = d.Units===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
|
|
|
|
|
|