SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 find duplicate fields in db
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Stripes
Starting Member

1 Posts

Posted - 01/22/2013 :  05:38:54  Show Profile  Reply with Quote
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

  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000