SQL - 将两列一起计数

SQL - Count two columns together

我正在尝试将多列计为一列。例如:

Table 1(书籍):

ID BookName Genre SubGenre
1 Name1 1 3
2 Name2 2 1
3 Name3 4 2

Table 2(流派):

ID Genre
1 Horror
2 Drama
3 Romance
4 Sci-Fi

我希望能够将流派和子流派算作一个来创建 table 的:

结果:

Genre Count
Horror 2
Drama 2
Romance 1
Sci-Fi 1

任何帮助将不胜感激。谢谢

尝试以下查询-

SELECT t.Genre, Sum(t.cg) AS Count
FROM (

SELECT t2.Genre, Count(t1.Genre) AS cg
FROM Table2 as t2 LEFT JOIN Table1 as t1 ON t2.ID = t1.Genre
GROUP BY t2.Genre

UNION ALL 

SELECT t2.Genre, Count(t1.SubGenre) AS cg
FROM Table2 as t2 LEFT JOIN Table1 as t1 ON t2.ID = t1.SubGenre
GROUP BY t2.Genre

) as t GROUP BY t.Genre;