Jump to content

Single Table Pivot Query


Recommended Posts

Hello,

 

I would like to create a query from a single table with the following columns.

 

SEQNO is a unique key

 

Name  ID  Amount  Date            JOBID        SEQNO

Mark    9        200    1/2/09        1001              1

Peter  3        300    1/2/09        1001            2

Steve  1        200    2/2/09        1001            3

Mark    9        200    3/2/09        1001              1

Peter  3        300    4/2/09        1001            2

Steve  1        200    5/2/09        1001            3

Hally 1        200      5/2/09        1002            3

 

The query should output in this format by SUBJOBID :-

 

NAME      ID    1/2    2/2    3/2    4/2    5/2              JOBID

Mark        9      200  NULL    200    NULL  NULL            1001 

Peter      3      300    NULL  NULL    300    NULL            1001 

Steve      1      NULL  200    NULL    NULL    200            1001 

 

I have been going over pivot queries for this. But I don't seem to get anywhere. Could some one help ?

 

 

Link to comment
https://forums.phpfreaks.com/topic/157459-single-table-pivot-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.