Multiple rows into one row

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chicagoboy27

    Multiple rows into one row

    Hello I am wondering if this is possible.

    I have a two tables one contains Plan information and another that
    contains product information about the plan

    ex:
    Plan table
    PlanID Plan_name
    1 a
    2 b

    Product Table
    ProductID PlanID Comments
    1 1 com1
    2 1 com2
    3 1 com3

    What I am looking to do if possible would be the following

    Plan Product1 Comments1 Product2 Comments2
    1 1 com1 2 com2


    I am wondering down what path I should explore cause I am new to this.
    I am using sql 2005

  • David Portas

    #2
    Re: Multiple rows into one row

    Chicagoboy27 wrote:
    Hello I am wondering if this is possible.
    >
    I have a two tables one contains Plan information and another that
    contains product information about the plan
    >
    ex:
    Plan table
    PlanID Plan_name
    1 a
    2 b
    >
    Product Table
    ProductID PlanID Comments
    1 1 com1
    2 1 com2
    3 1 com3
    >
    What I am looking to do if possible would be the following
    >
    Plan Product1 Comments1 Product2 Comments2
    1 1 com1 2 com2
    >
    >
    I am wondering down what path I should explore cause I am new to this.
    I am using sql 2005
    Take a look at PIVOT in Books Online. Also Itzik Ben-Gan has articles
    on PIVOT in the last two issues of SQL Server Magazine. www.sqlmag.com

    --
    David Portas, SQL Server MVP

    Whenever possible please post enough code to reproduce your problem.
    Including CREATE TABLE and INSERT statements usually helps.
    State what version of SQL Server you are using and specify the content
    of any error messages.

    SQL Server Books Online:

    --

    Comment

    • Chicagoboy27

      #3
      Re: Multiple rows into one row

      Thanks I will explore that option...

      David Portas wrote:
      Chicagoboy27 wrote:
      Hello I am wondering if this is possible.

      I have a two tables one contains Plan information and another that
      contains product information about the plan

      ex:
      Plan table
      PlanID Plan_name
      1 a
      2 b

      Product Table
      ProductID PlanID Comments
      1 1 com1
      2 1 com2
      3 1 com3

      What I am looking to do if possible would be the following

      Plan Product1 Comments1 Product2 Comments2
      1 1 com1 2 com2


      I am wondering down what path I should explore cause I am new to this.
      I am using sql 2005
      >
      Take a look at PIVOT in Books Online. Also Itzik Ben-Gan has articles
      on PIVOT in the last two issues of SQL Server Magazine. www.sqlmag.com
      >
      --
      David Portas, SQL Server MVP
      >
      Whenever possible please post enough code to reproduce your problem.
      Including CREATE TABLE and INSERT statements usually helps.
      State what version of SQL Server you are using and specify the content
      of any error messages.
      >
      SQL Server Books Online:

      --

      Comment

      Working...