• boehnc (9/17/2012)


    I need to bring back in a table unique patients where dxcode = 23 or 34.

    one patient can have 23 and 34..I just need to bring back whether they had one or the other. If I do a left outer join, a patient with 23 and 34 will bring back two entries. How do I have it bring back just one unique entry? Thanks

    If you setup schema and data, we'll be able to provide you actual code, but in the meantime, psuedocode will have to do:

    SELECT

    mt.ID, MAX( c.dxCode)

    FROM

    MainTable AS mt

    JOIN

    dxcodes AS c

    ON mt.Id = c.Id

    GROUP BY

    mt.ID


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA