Reputation: 452
I have a column chart that the user can insert a value in every year.
my table is look like this.
is there any possibility to view my table like this?
| Course | 2013 | 2014 | 2015 | // column name
| BSIT | 657 | 453 | 424 |
| Education| 657 | 453 | 424 |
I want to view like that so that my column chart display look like this
I don't know if this question is possible to do. I wish...
Upvotes: 0
Views: 29
Reputation:
If its limited to a small amount of years(not something like then 20 previous years) then it can be achieved with conditional aggregation like this:
SELECT Course,
max(CASE WHEN year = 2013 then value end) as year_2013,
max(CASE WHEN year = 2014 then value end) as year_2014,
max(CASE WHEN year = 2015 then value end) as year_2015,
.....More years if you need
FROM YourTable
GROUP BY Course
Upvotes: 2