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 |
Vack
Aged Yak Warrior
530 Posts |
Posted - 2014-07-28 : 14:35:33
|
How can I pull out duplicate records based on certain fields? Table called BankI want to pull out records that have duplicate inv_no, cus_no, amount,ordernumNot all the fields are the same in each record. But I want the records that have these fields that are the same. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-07-28 : 14:40:32
|
select inv_no, cus_no, amount, ordernum, count(*)from Bankgroup by inv_no, cus_no, amount, ordernumhaving count(*) > 1Add a unique constraint to these to prevent this in the future (if this condition is not supposed to happen).Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|