How to break out values in a row to be in its own field based on a date value

31
January 12, 2019, at 5:30 PM

In the Table Setup below you will see that the Amount data is broken down in various rows in the table. I am creating a view where i want to break this out where each Amount value is in its own field based on the CreatedDt field. So the fields would be Fee1, Fee2, Fee3 and so on if there were more fees. I am having trouble coming up with the logic to do this.

I have tried to do first and last value, min and max, different case statements and i am not seeming to have success with any of these methods.

SELECT
`afpd`.`AppsID` AS `AppID`,
sum(case when ( `afpd`.`TxnTypeId` = 2 )  then `afpd`.`Amount` end)  as fee1 
FROM
(
    ( `appfee` `afpd` JOIN `tracking` `tra` ON ( ( `afpd`.`AppsID` = `tra`.`tci_application_id` ) ) )
    JOIN `faap` `fad` ON ( ( `afpd`.`AppsID` = `fad`.`ApplicationID` ) ) 
) 
WHERE
( `tra`.`tci_fee_submitted` = 11 ) 
GROUP BY
`afpd`.`AppsID`

Table Setup:

TXNID    AppID    TXnType    Amount      CreatedDT   
1429513  3827558    2    -29.00      2017-11-01 06:18:00
1388653  3827558    2    -29.00      2017-10-15 06:24:00
1811017  3827558    2    -31.00      2018-05-02 07:07:00

The above is the way the table looks where i am pulling the data. As you can see the Amounts are stored as rows and i want to take this and create fields fields: Fee1, Fee2, Fee3 and have Fee1 be the latest CreatedDt, Fee2 would be the middle CreatedDt and Fee3 would be the most recent CreateDt.

READ ALSO
SQL-queries in server.js or in react-component file?

SQL-queries in server.js or in react-component file?

I'm totally new at using Expressjs and React

53
Laravel app using Jaws Maria DB on Heroku getting MYSQL errors

Laravel app using Jaws Maria DB on Heroku getting MYSQL errors

I have a Laravel app on Heroku using Maria DB as a Add onMy App is up and running

32
How can I modify the jetpack code so that when I publish a post and jetpack publish it on twitter does not show the url of the new post?

How can I modify the jetpack code so that when I publish a post and jetpack publish it on twitter does not show the url of the new post?

Hi ppl i need help with this because it shows the url in twitter and it comes from and ugly subdomain so i dont want to show the url of the new post just send a tweet with text

46
How to write ApplicationContext xml equivalent java code

How to write ApplicationContext xml equivalent java code

I want to make java based configurationI have already xml configuration in my project and it's worked

66