Reputation: 431
I have a table like this :
Categories
=================================
Category | subcategory | Text
---------------------------------
film English The Lost World
film Hindi sholai
music English Enrique
Music Hindi A.R Rahman
I want to categerize the result with their count. the result should be like this
======================
Category/ | count
Sub Cate
----------------------
film 2
music 2
english 2
Hindi 2
I want get the result like the follwing
Please help me to achive this
Thanks and Regards
Shibin
Upvotes: 1
Views: 196
Reputation: 6543
SELECT Category AS 'Category/SubCategory', COUNT(*) AS 'Count'
FROM Categories
GROUP BY Category
UNION
SELECT SubCategory AS 'Category/SubCategory', COUNT(*) AS 'Count'
FROM Categories
GROUP BY SubCategory
Upvotes: 2