Home Forums SQL Server 2008 T-SQL (SS2K8) Sql Query - get most recent data and put record numbers into columns RE: Sql Query - get most recent data and put record numbers into columns

  • Great sample data. i have a question, how do you know there will only be 12 ExternalID's? is that a business rule. how will you deal with patients who have more than 12 ExternalID's if there are more?

    as far as the actual query goes take a look at jeff moden's cross tabs and pivot article http://www.sqlservercentral.com/articles/T-SQL/63681/

    EDIT: Grabbed the wrong link, fixed.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]