首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

sql求和有关问题

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

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 totalfrom 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;

热点排行