My SQL query is:
SELECT * FROM
(SELECT * FROM transactions) AS T1
PIVOT(SUM(amount) FOR month IN([March], [April], [May])) AS pvt
My Table is as follows:
id payee amount month
1 Tom 90 March
3 Tom 66 April
4 Tom 89 May
10 Jasmine 125 April
11 Nancy 151 March
12 Jasmine 175 April
13 Nancy 152 April
My desired output is:
payee March April May
Tom 90 66 89
Jasmine -- 300 --
Nancy 151 152 --
I am running this query in a phpMyAdmin for my website the Error presented is as follows:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PIVOT(SUM(amount) FOR month IN([March], [April], [May])) AS pvt