Hi I have mysql table as below

id | item_id | date | received

Now I want to make a html table from above data where columns are year and rows are months. and value will be sum of received on month _ year. like below demo

| | 2018 | 2019 | 2020 | 2021 | | Jan | --- | --- | --- | --- |
| Jan | 263 | 452 | 323 | 164 |
| Feb | 424 | 135 | 295 |blank |
| Mar | 105 | 437 | 241 | 209 |
| Apr | 280 | 294 | 267 | 159 |
| May | 441 | 348 | 212 | 261 |
| Jun | 188 |blank | 426 | 358 |
| Jul | 226 | 126 | 224 | 132 |
| Aug | 312 | 491 | 343 | 413 |
| Sep | 400 | 193 | 437 | 343 |
| Oct | 235 | 323 | | 254 |
| Nov | 249 | 496 | 259 | 263 |
| Dec | 176 | 312 | 207 | 274 |

so the report can show received in particular month in particular year.

is it possible ? Plz help

From the web "Unfortunately, MySQL does not have PIVOT function". I'd consider prior answers found with https://www.google.com/search?&q=pivot+data+from+mysql

https://codingsight.com/pivot-tables-in-mysql/ shows a few solutions but the easy path appears to be dbForge Studio for MySQL which you can get a 30 free trial. Why I'd go with dbForge is simple. Read http://www.artfulsoftware.com/infotree/qrytip.php?id=78 and you see your workload goes up pretty quickly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.