Duplicate Records

  • In my query below, I want to have records in which event date_received is in Current month, but event_note create_date does not exist OR event_note_type is 29 and event_note create_date is in current month and event date_received does not exist OR event_note_type is 29 and event create_date is in current month and event date_received is in current_month. Running this qry gives me two rows where i am checking event date_received is in current month and event note_type does not exist. One shows Null in

    Create_date.

    Qry:

    HAVING

    (

    ( ev.date_received between @Cmonth_start_date and @Cmonth_end_date AND max(en.note_type_fk) is null)

    OR

    ( en.note_type_fk='29'

    and

    (

    (ev.date_received is null and (max(en.create_date) >= @Cmonth_start_date and max(en.create_date) <= @Cmonth_end_date))

    or

    ((ev.date_received >= @Cmonth_start_date and ev.date_received <= @Cmonth_end_date)

    and ( max(en.create_date) > @Pmonth_end_date ) )

    )

    )

    )

    e.g. of the duplicate records. In this case, I don't want NULL in create_date. All I want is the second record not the first one.

    4120483PFIZER ANN ARBOR, MI PGRDNULLFEMALE41FamilySelf05/02/2003Re OpenSelfLiteratureMaritalNULLRoutineSpouse/Significant OtherNULLHomemaker 24571Provider Office

    4120483PFIZER ANN ARBOR, MI PGRD2003-06-09 20:27:09.003FEMALE41FamilySelf05/02/2003Re OpenSelfLiteratureMaritalClinicalRoutineSpouse/Significant Other15Homemaker 24571Provider Office

    Thanks in Advance!

    Edited by - bhavnabakshi on 08/08/2003 12:21:50 PM

    Edited by - bhavnabakshi on 08/08/2003 12:22:31 PM

  • This was removed by the editor as SPAM

  • If you were to use IsNull earlier and if it is a NULL, converting it to a date that is sure to be outside of your range, it could solve your problem.

    AndreQ

    HAVING

    (

    ( IsNull(ev.date_received, '01/01/1901') between @Cmonth_start_date and @Cmonth_end_date

    AND max(en.note_type_fk) is null)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply