标签: sql database sqlite
此表的操作方式 获取此表(对等方应相同,即,其中peer =程序中指定的对等方) 动作0为减,动作1为加
答案 0 :(得分:1)
您似乎想要一个简单的汇总:
select whom, sum(action) as plus, sum(1 - action) as minus from t group by whom;
答案 1 :(得分:1)
有条件聚合:
select whom, sum(action = 1) plus, sum(action = 0) minus from tablename where peer = ? group by whom