求项目ID为1000的盈亏
表名为:T
字段:ID P_ID AMOUNT TYPE(1:收入 2:支出)
select sum(case when TYPE=1 then AMOUNT when TYPE=2 then -AMOUNT end) from T where P_ID='1000'
求项目ID为1000的盈亏
表名为:T
字段:ID P_ID AMOUNT TYPE(1:收入 2:支出)
select sum(case when TYPE=1 then AMOUNT when TYPE=2 then -AMOUNT end) from T where P_ID='1000'