I want to get year wise data in MySQL pivot table.I have one table
id | Name | Amount | Date
1 | ABC | 50 | 2018-05-16
2 | PQR | 60 | 2017-07-16
3 | LMN | 40 | 2017-01-16
I want result Like
Type | 2018 | 2017
total | 1 | 2
SUM | 50 | 100
Also date column values should be dynamic. If new year date is entered,The pivot table should contain that year i.e. if date value is 2019-01-22 then pivot table will show 2019 as column