对不起,伙计们,我试过了,但我不得不问。我不会带着这个去任何地方。
Here's my table `likes`:
"id" "type" "parent" "country" "votes"
"1" "1" "0" "US" NULL
"2" "2" "1" "US" NULL
"3" "3" "2" "US" NULL
"4" "10" "3" "US" "5"
"5" "10" "3" "US" "15"
"6" "10" "3" "US" "25"
"7" "3" "2" "US" NULL
"8" "10" "7" "US" "40"
"9" "10" "7" "US" "25"
"10" "10" "7" "US" "60"
"19" "3" "1" "US" NULL
"20" "10" "19" "US" "10"
"21" "10" "19" "US" "20"
"22" "10" "19" "US" "30"
从此,我试图select distinct parent , sum votes where type = 10 and country = 'us'
我试过这个:SELECT SUM(likes.votes) FROM (SELECT DISTINCT parent, votes FROM likes where type = 10) likes;
但我最终得到了非常奇怪的结果。
我怎样才能做到这一点?
我想要得到的结果是这样的:
parent | total
3 | 45
7 | 125
9 | 60