Query for display Rows value in column wise

  • Hi everyone

    I have two table

    Table1

    id date

    101 10/01/2007

    102 10/04/2007

    103 10/05/2007

    104 10/06/2007

    Table 2

    id Plan

    101 A

    101 B

    102 A

    102 B

    102 C

    102 D

    103 C

    103 D

    104 A

    i need a query to display the following result

    id date A B C D

    101 10/01/2007 Y Y N N

    102 10/04/2007 Y Y Y Y

    103 10/05/2007 N N Y Y

    104 10/06/2007 Y N N N

    thanks in advance

    regards

    sthanika

  • Hi

    I think u can use the pivot operator for this. search this other sites for how to use pivot.

    "Keep Trying"

  • It's not nice to cross post 😉

    [highlight]http://www.sqlservercentral.com/Forums/Topic407185-338-1.aspx[/highlight]

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply