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 |
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2011-09-08 : 09:32:43
|
| Hi,I have been trying to figure out this formula for a couple of days now and I can’t. I need to be able to pull todays data, but then match it with the other data in the system (clm) to see if there are any duplicates field (clm_84b), but it has to have a different claim numbers associated with them (clm_id1). Exampleclm_id1 clm_84b clm_batch clm_rcvd03143749 201107131133 00160354 08/10/201103177734 201107131133 00162808 09/06/2011This is what I have so far. This is pulling claims data that is not in my table #orgclaim.drop table #orgclaimSelect clm_id1 as ClaimID, clm_84b as OrgClaimID,clm_batch as Batch INTO #OrgClaim from impact.dbo.clm Where clm_clir = '00001674'and clm_rcvd = ‘09/06/2011’select clm_id1, clm_84b, clm_batch from impact.dbo.clm where clm_84b in (Selectclm_84b From impact.dbo.clm Where clm_clir = '00001674'group by clm_84b HAVING COUNT (clm_84b) > 1) ORDER BY clm_84bThanks for you help in advance! |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2011-09-08 : 10:15:23
|
| I was able to figure it out....drop table #orgclaimSelect clm_id1 as ClaimID, clm_84b as OrgClaimID,clm_batch as Batch INTO #OrgClaim from impact.dbo.clm Where clm_clir = '00001674'and clm_rcvd = '09/06/2011'---'09/06/2011'----(clm_rcvd > GETDATE() - 2)---yesterdays dateselect clm_id1, clm_84b, clm_batch,clm_rcvd from impact.dbo.clm Right Join #orgclaim on clm_84b = OrgClaimIDwhere clm_clir = '00001674' and clm_84b in (Selectclm_84b ---OrgClaimID From impact.dbo.clm ----#orgclaimWhere clm_clir = '00001674'group by clm_84b --OrgClaimID HAVING COUNT (clm_84b) > 1) ---OrgClaimIDORDER BY clm_84b |
 |
|
|
|
|
|
|
|