我得到了这样的桌子votes
"id" "votedElm" "voteType" "voteProcessed" "country"
"1" "4" "0" "0" "US"
"2" "5" "0" "0" "US"
"3" "6" "1" "0" "US"
"4" "8" "0" "0" "US"
"5" "9" "0" "0" "US"
"6" "10" "0" "0" "US"
"7" "10" "0" "0" "US"
"8" "10" "0" "0" "US"
"9" "8" "1" "0" "US"
"10" "9" "1" "0" "US"
"11" "20" "1" "0" "US"
"12" "10" "1" "0" "US"
"13" "10" "1" "0" "US"
"14" "20" "0" "0" "US"
"15" "22" "0" "0" "US"
"16" "20" "0" "0" "US"
"17" "21" "0" "0" "US"
"18" "10" "0" "0" "US"
"19" "10" "0" "0" "US"
"20" "20" "0" "0" "US"
"21" "21" "0" "0" "US"
"22" "22" "0" "0" "US"
"23" "22" "0" "0" "US"
"24" "22" "1" "0" "US"
我使用这个 sql 来获得不同的喜欢并从中求和:
select votedElm, count(votedElm) from votes where country = 'US' and voteType = 0 group by votedElm;
但是,在那张桌子上,我有voteType 0 and 1
. 0
是一+
票,1
是一-
票。
在同一个sql中可以+
加票,-
减票吗?而不是为此有2个不同的查询?
我可以这样做吗?