表结构如下:金额      类型(0为支出/1为收入)
-------------------------------
100          0
300          1
44           0
33           1希望能够统计 表内 收入和支出总和各为多少谢谢了。。

解决方案 »

  1.   

    表结构如下:金额      类型(0为支出/1为收入)
    -------------------------------
    100          0
    300          1
    44           0
    33           1希望能够统计 表内 收入和支出总和各为多少
    select 类型 , sum(金额) 金额 from tb group by 类型
      

  2.   

    金额account,类型type,表table
    select sum(account) 金额,type 类型 from [table] group by type
    --------------------------------------------------------
      

  3.   

    select 类型 ,sum(金额) from 表 group by 类型
      

  4.   

    create table testtablea
    (
    price int,
    type int
    )insert into testtablea values (100,0)
    insert into testtablea values (300,1)
    insert into testtablea values (44,0)
    insert into testtablea values (33,1)select top 1 shouru = (select sum(price) from testtablea where type= 1),zhichu = (select sum(price) from testtablea where type= 0),zhonghe = (select sum(price) from testtablea)
    from testtablea