This is my table “rating” in my database.
attraction customer rate
------------------------------------
attrac1 cust1 like
attrac2 cust1 dislike
attrac1 cust2 like
What SQL should i write to make the output become like this
attraction like dislike
----------------------------------
attrac1 2 0
attrac2 0 1
I tried this
SELECT a_id,
(SELECT COUNT(rate) FROM rating WHERE rate = 'like') as 'Like',
(SELECT COUNT(rate) FROM rating WHERE rate = 'dislike') as 'Dislike'
FROM rating
But I cant get the result that I want.
This is one approach: