• prakashdotc (12/22/2008)


    Hi All,

    Here's my description about my Query

    i Have a Table with Columns as ProdId, Value, Date

    Users will enter some value for each product on various date

    The Task is to Retrieve the last 5 days record, with 5 Date's as it's header like

    --------------------------------------------------------------------------------------------

    ProductId - Date 1 - Date 2 - Date 3 - Date 4 - Date 5

    --------------------------------------------------------------------------------------------

    1 - 234 - 989 - 876 - 7686 - 9878

    2 - 34 - 99 - 876 - 66 - 87

    --------------------------------------------------------------------------------------------

    Thanks

    Prakash.C

    In SQL 2005, use PIVOT function you get expected result, for more info see SQL BOL.