1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MySQL Pivot

Discussion in 'Databases' started by neilfurry, Jan 24, 2018.

  1. #1
    Hi Mate,
    SEMrush
    I need some help here, i want to create a Pivot table to display the output i want.

    here is my database table:

    sample.png

    I want it to display

    clientid | lastname | firstname | Job 1 | Amount | Job 2 | Amount
    283641 Rey Ann 04-18-2017 268.00 07-11-2016 708.00


    Where Job Columns are dynamic which holds the date of the job and the amount is also dynamic that holds the amount of job.

    Can you help me create a PIVOT out of the table i presented and the output i need.

    Thank you

    Neil

    Job # is dynamic as it holds the date of the job a client has, so if client x has 4 jobs, it will display 4 Jobs and Amount columns. and if the client has only 2 Jobs, it will display 2 Jobs and Amount and two Jobs will be 0
     
    Last edited by a moderator: Jan 24, 2018
    neilfurry, Jan 24, 2018 IP
    SEMrush
  2. jestep

    jestep Prominent Member Premium Member

    Messages:
    3,640
    Likes Received:
    212
    Best Answers:
    18
    Trophy Points:
    330
    #2
    jestep, Jan 31, 2018 IP