• vijay-367524 (4/15/2013)


    Hello,

    I have a sql table as below

    AutoIdPIDItemIdItemItemValue Date

    7560 432 1 Wbc 4 05/05/12 00:00

    7561 432 2 HCT 4 05/05/12 00:00

    7562 432 3 W/L/M 4 05/05/12 00:00

    7563 432 4 Bilirubin 485 06/05/12 00:00

    7564 432 1 Wbc 45 06/05/12 00:00

    7565 432 2 HCT 4 06/05/12 00:00

    I tried to use the pivot to display the result as below. But it didn't worked for me. Does any one have any idea on how to get this done?

    AutoIdPIDItemIdItem 05/05/1206/05/12

    7560 4321Wbc 4

    75614322 HCT 4

    75624323 W/L/M 4

    75634324 Bilirubin485

    7564 4325 Wbc 45

    7565 4326 HCT 4

    Thanks,

    VIjay

    Check out the links in my signature about cross tabs. I suspect you will end up wanting to use the dynamic version.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/