日期:2014-05-17  浏览次数:20776 次

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

------解决方案--------------------
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=1

LZ这表有点高级哦
------解决方案--------------------
SQL code

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

------解决方案--------------------
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;