Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.