I have results like this, the Annual is dynamic and may have X amount of ranges
+-----------+---------+-----------+
| Annual | Revenue | Completed |
+-----------+---------+-----------+
| 2020/2021 | 1000 | Yes |
+-----------+---------+-----------+
| 2021/2022 | 2000 | Yes |
+-----------+---------+-----------+
| 2022/2023 | 2500 | No |
+-----------+---------+-----------+
I'm looking to have results like this:
+-----------+-----------+-----------+-----------+
| Annual | 2020/2021 | 2021/2022 | 2022/2023 |
+-----------+-----------+-----------+-----------+
| Revenue | 1000 | 2000 | 2500 |
+-----------+-----------+-----------+-----------+
| Completed | Yes | Yes | No |
+-----------+-----------+-----------+-----------+
Here's what I got so far, I can execute on my local but can't seem to get it to execute on sqlfiddle: http://sqlfiddle.com/#!18/a4c61/4
I've looked at examples all over stackoverflow but couldn't seem to find an exact case like mine.
Please help if you can, thank you!
Sql version: Microsoft SQL Azure (RTM) - 12.0.2000.8 May 15 2020 00:47:08



