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.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 find duplicate fields in db

Author  Topic 

Stripes
Starting Member

1 Post

Posted - 2013-01-22 : 05:38:54
Hi i need to write to find where parameter 1 is a bank account no, i need to see where debits are ran against this account no for different companies. The end result should populate a grid in delphi, showing the same account no over and over for each company that has debited the account. I have 2 tables clients which includes the client info and a paymentsdue table which payment details. They are join on a company serialno field. The query i have is below, the serialno included are all the companies is question. This however does not just show me the duplicate entries but all of them. Any help is much appreciated.

SELECT c.Accountno,c.serialno,c.ClientID,e.DueDate
FROM ebtpaymentsdue e inner join clients c
on e.SerialNo = c.SerialNo and e.ClientNo = c.ClientNo and c.AccountNo = c.AccountNo
where e.DueDate >= GETDATE() and e.DueDate <= getdate() + 10
and 1 < (select count(*) from clients c1 where c1.AccountNo = c.AccountNo) and c.serialno in (
'DC9-35-CE7','438-12-6FA','3D8-3F-6F6','4A8-3A-318','4A8-3A-318','228-1E-3EC','2D8-28-1F6','878-71-014','988-15-1E9','CE8-12-7E7'
,'EE8-1F-6F0','498-73-5E1','978-3B-3EA','8B8-0F-3E7','9D8-20-007','6A8-10-1E6','DB8-72-214','688-26-0E3','068-15-010','1F8-16-31F'
,'EC8-19-1FF','989-26-CE3','6D8-07-0FB','D98-11-2E7','028-15-5CE','498-28-5EB','D58-1B-6FA','298-2D-0EF','298-3C-312','7F8-3C-3E8'
,'728-25-205','328-28-6F6','E58-2D-51C','308-1A-007','808-04-7E6')
GROUP BY c.Accountno,c.serialno,c.ClientID,e.DueDate
ORDER BY c.Accountno DESC

   

- Advertisement -