Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Posts
    62

    Unanswered: Select data horizontally

    HI,

    I have the following table:

    Policy Sequence LossDate Description Amt
    123 1 9-1-2012 property 100
    123 2 10-1-2012 property 200
    345 1 9-1-2012 property 100
    345 2 10-1-2012 property 100
    678 1 9-1-2012 property 100

    I want to select the data as follows:

    Policy LossDate1 Description1 Amt1 LossDate2 Description2 Amt2
    123 9-1-2012 property 100 10-1-2012 property 200
    345 9-1-2012 property 100 10-1-2012 property 100
    678 9-1-2012 property 100 NULL NULL NULL

    Is there a way to do this using T-SQL?

    The max sequence number can vary, so far the max has been 12, but may be higher in the future.

    thanks

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    (1)
    The max sequence number can vary, so far the max has been 12, but may be higher in the future.
    Why not include those data in your sample data?


    (2) Are sequence numbers begin from 1 and continuous(no gaps) for each Policy?


    (3)
    I want to select the data as follows:

    Policy LossDate1 Description1 Amt1 LossDate2 Description2 Amt2
    ...
    Do you want only two data or all rows' data, when there were more than 2 rows for a Policy?

  3. #3
    Join Date
    Aug 2012
    Posts
    30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •