troubleshooting Question

Compare date fields in SQL server

Avatar of Jason Yousef
Jason YousefFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
27 Comments1 Solution1063 ViewsLast Modified:
Hi all,

I've a flat file that I cleaned the data out using SSIS, the output looks like that :


MEDICAL    ADMIT          PATIENT     PATIENT                       DATE OF       DX
REC NO     DATE           NUMBER        NAME                      DISCHARGE   Code     DRG #

123613    02/16/09       12413209  MORIBALDI ,GEMMA       02/19/09   428.20     988    
130897    01/23/09       12407193  TINLEY ,PATRICIA           01/23/09   535.10     392    
139367    02/27/09       36262509  THARPE ,GLORIA            03/05/09   562.10     392
   
141954    02/25/09       72779499  SHUMATE ,VALERIA       02/25/09   112.84     370  
141954    03/07/09       36271732  SHUMATE ,VALERIA       03/10/09   493.92     203  
 
145299    01/21/09       12406294  BAUGH ,MARIA               01/21/09   366.17     117  


and the report (final results) attached in the screen shot from the final excel report.

so  what's happening is IF the same name or same account number is duplicate, that means the patient has entered the hospital again and needs to be included in the report.

what I need to do is...

Eliminate any rows that is NOT duplicate (not everybody in this file has been admitted again)
and compare the dates to get the ReAdmitdate and ReDischargedate

I dumped the data into a SQL table and trying to compare the dates to figure out "ReAdmitdate" and "ReDischargedate"

any help is appreciated.
Thanks
readmin.jpg
ASKER CERTIFIED SOLUTION
Rajkumar Gs
Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 27 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 27 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros