I have two tables. I want to combine this tables to get the results like below:
Table_1
RegNo Class_id Name Address
------------------------------------------------
ABC/R/13-14-1 1 Name1 Address1
ABC/R/13-14-2 2 Name1 Address1
ABC/R/2014-15-1 1 Name1 Address1
ABC/R/2014-15-2 3 Name1 Address1
ABC/R/13-14-3 1 Name1 Address1
------------------------------------------------
Table_2
Class_id Class
----------------------
1 IA
2 IB
3 IC
----------------------
i need the result like:
Class 2013 2014
--------------------
IA 2 1
IB 1 0
IC 0 1
--------------------
I am using Group by to get the results in a separately for each year, but I am not able to get the year in column-wise format like the requirement. Any help is highly appreciated.
Thanks in advance.
If condition you used in your query works for your data then you can use this query:
Output: