Compare date fields in SQL server

Posted by huslayer on Stack Overflow See other posts from Stack Overflow or by huslayer
Published on 2010-04-07T13:22:04Z Indexed on 2010/04/07 13:23 UTC
Read the original article Hit count: 320

Filed under:
|
|
|
|

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. ![alt text][1]

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

[link text][1]

© Stack Overflow or respective owner

Related posts about ms

Related posts about sql