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 2008 Forums
 Transact-SQL (2008)
 Difference between SQL statements

Author  Topic 

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2013-03-27 : 09:36:54
Hi,
Both of these check for duplicate rows but what is the difference between them?

select distinct source_file, claimNo, memberid, count(*)
from dbo.Claims_Header_2013
group by source_file, claimNo, memberid
having count(*)>1

select distinct source_file
from dbo.Claims_Header_2013
group by source_file, claimNo, memberid
having count(*)>1

thank you

ITM

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-03-27 : 09:42:17
This is the main logic..... ( logic for checking duplicate combination of source_file, claimNo, memberid)

group by source_file, claimNo, memberid
having count(*)>1

If you need the source_file, claimNo, memberid, count(*) cnt in the display, then consider first query; Otherwise use second query
Go to Top of Page

itmasterw
Yak Posting Veteran

90 Posts

Posted - 2013-03-27 : 10:25:17
Thank you that made it clearer

ITM
Go to Top of Page
   

- Advertisement -