Firebird摘要字段计算

时间:2013-12-22 18:33:36

标签: firebird summary

我想这样做:

select 
  id, 
  sum(field1) as a,
  sum(field2) as b,
  a - b as result group by id;

但火鸟显示“列未知。”。第“a - b行”中的错误。怎么做到这一点。感谢..

1 个答案:

答案 0 :(得分:1)

在减法中也写出sum(),即

select 
  id, 
  sum(field1) as a,
  sum(field2) as b,
  sum(field1) - sum(field2) as result 
group by id;