• This appears to be a reporting pivot of timeline rows for a report of some kind regarding the diagnosis applied to a patient.

    Look to the report. Can this be sub-reported intelligently instead of trying to force the pivot? If not, I agree with the above, either crosstab it or PIVOT it. Either will most likely get you performance improvements.


    - 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