现在我要统计表里的三列的记录的条数,并将各列的记录的条数求和,请问语句怎么写
比如列名:uni、mob、tel,表名:send

解决方案 »

  1.   

    米看明白,你是想求 共有几条记录 ?select count(*) from send 不是可以求出有几条记录 ?
      

  2.   

    select count(*) from send where uid is not null; 像这样?
      

  3.   

    表:
    uni mob tel
     1   1   0
     1   0   0
     1   0   0
    把这三列的记录条数count出来,再加起来。即3+1+0
    select sum(select count(uni),count(mob),count(tel)from send) from send;
    知道这个sql语句不对,就是问了表达这个意思。请问改怎么写啊?
      

  4.   

    select (sum(uni) + sum(mob) + sum(tel)) as total from send;
      

  5.   

    楼主 你这句话“把这三列的记录条数count出来,再加起来。即3+1+0
    ”是不对的 你给出的数据每一列都有三条记录 真要是count(tel)应该是3 楼主是想把每一列内的数据求和然后再把这三个和加起来吧 
    按照我的理解我写的SQL如下select (sum(uni)+sum(mob)+sum(tel)) sum from send
      

  6.   

    对于题我是这么理解的-_-
    select count(uni),count(mob),count(tel), sum(uni),sum(mob),sum(tel) from send;
    or
    select count(*),sum(uni),sum(mob),sum(tel) from send;
      

  7.   

    我是这个意思:第一列有3条,第二列有1条,第三列是0条。然后用sum求出这三个列的和(总条数),sql语句怎么写
      

  8.   

    我是这个意思:第一列有3条,第二列有1条,第三列是0条。然后用sum求出这三个列的和(总条数),sql语句怎么写
      

  9.   

    我比较纳闷了,还有一个表里不同的字段行数不一致的情况?晕阿!!!!!
    按你说的意思是不是第一列有三条有值得,null值是不是不算一条记录?
      

  10.   

    不是看记录数,是看条数,null的不算
      

  11.   

    select tab.cuid+tab.cmod+tab.ctel from
    (select 
    (select count(*) from send where uid is not null) as cuid,
    (select count(*) from send where uid is not null) as cmod,
    (select count(*) from send where uid is not null) as ctel
    from dual)
    tab where 1=1LZ这表有点高级哦
      

  12.   


    select ((select count(uni) from send where uni is not null)
           + (select count(mob) from send where mob is not null)
           + (select count(tel) from send where tel is not null)) as total
    from dual
      

  13.   

    create table a (
       aa number(10),
       bb number(10),
       cc number(10)
    )insert into a values(1,1,0);
    insert into a values(1,0,1);
    insert into a values(1,0,0);select sum(aa)+sum(bb)+sum(cc) from a;
      

  14.   

    非常感谢,这个弄好了。可是又出了新的错误:
    int i=this.getJtN().queryForInt("SELECT count(SP_NUMBER) FROM T_DX_SMS_TASK_RECEIVE m where 1=1" + sqlWhere);
    map=this.getJtN().queryForMap("SELECT * FROM T_USER_MANAGE WHERE ID=?",new Object[]{map.get("id")});
    map.put("dxrcount", i);
    jjd.setForm(map);
    return jjd.getData();
    我的代码是这样的,报下面的错误:
    Incorrect result size: expected 1, actual 0(好像是第二个sql语句报出来的),请问大家是怎么回事
      

  15.   

    我给你一个建议  把复杂的sql写到存储过程里面  写在页面中看着头就疼!