Output of a query in row intead a column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhulok
    New Member
    • Jul 2007
    • 2

    Output of a query in row intead a column

    Hi Friends,
    I am googling from last couple of days to find the answer. Below is the problem which I am trying to solve using SQL Server 05,

    Col1-------Col2--------Col3
    A ....... 1/1/2008.....Y
    A ....... 1/2/2008.....N
    B ....... 1/1/2008.....N
    B ....... 1/2/2008.....N
    C ....... 1/1/2008.....Y
    C ....... 1/2/2008.....Y

    I am trying to capture a following output in a temporary table,

    -------------1/2/2008-------1/2/2008
    A ............Y.. ............... N
    B............ N.............. ...N
    C............ Y.............. ...Y

    I am trying to solve this problem but could not able to come out with a correct answer. Any suggestions to crack this are welcome.

    Thanks in advance

    Regards,
    bhulok
  • stubailey
    New Member
    • Feb 2008
    • 2

    #2
    Hi,

    Have a look at pivot and cross tab. This article may help.

    http://www.databasejou rnal.com/features/mssql/article.php/3516331

    Stu

    Comment

    • bhulok
      New Member
      • Jul 2007
      • 2

      #3
      Hi Stubailey,
      Thank you for a link. I tried Pivot table but it doesn't take characters in 'data field'. I am trying to generate output using sql query.

      Regards,
      bhulok

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        I don't think it will allow the "/" (slash). You might want to convert the name to COLYYYYMMDD format.

        -- CK

        Comment

        Working...