upVote DownVote
|true | 0
|true | 0
|0 | true
|true | 0
|true | 0
|0 | true
I have columns like this above in my sql table. I want to count the total number of upVotes - Downvotes just like stackOverflow. But for some reason I am having hard time with sql syntax.
SELECT COALESCE(sum(CASE WHEN upvote THEN 1 ELSE 0 END),0) from Ratings WHERE TopicID = :topicsID
I have seen the above sql query example somewhere but not sure I am heading in the right direction.Help is appreciated
true | trueorfalse | false?SUM(upVote)upvotecolumn with a boolean value is enough.