select a.dq,sum(decode(b.tel,null,0,1))
from area a,smsout b where dt<=sysdate and dt>sysdate-1 and a.dq=b.dq(+) group by a.dq;sum(decode(b.tel,null,0,1))
b.tel是空标记为0,非空为1,求和
from area a,smsout b where dt<=sysdate and dt>sysdate-1 and a.dq=b.dq(+) group by a.dq;sum(decode(b.tel,null,0,1))
b.tel是空标记为0,非空为1,求和
解决方案 »
- sql中的字符报错 - 大家帮忙看看
- ctxsys用户如何恢复
- 存储过程报错
- 先备份数据库,然后在数据库中增加n条记录,然后还原刚才备份的数据库,可发现增加的n条记录仍然存在
- 关于v$sql视图的一些问题,急,请教
- oracle中怎样把number类型转为integer类型,使用什么函数呢
- ORA-02041: 客户数据库未开始一个事务处理 ,这个问题你遇到过吗?
- 100分在线等待oracle安装问题
- 各位高手,小弟有个问题!请多多指教!!!!!来者有分!!!!!!
- 向数据库加新数据,求指教proc。
- 问一个很菜的问题 我怎么在一个指定的数据库里操作SQL语句???
- 大伙帮忙看看这句sql语句,为什么不行啊(关于order by的)
select dq,count(1) from smsout where trunc(dt)=trunc(sysdate) group by dq
问题二:
select a.dq,nvl(a.con,0) from (select dq,count(1) con from area group by dq) a,smsout b where trunc(a.dt)=trunc(sysdate) and a.dq(+)=b.dq
select b.name,nvl(sum(a.charge),0)
from report_acct_item a, acct_item_type b
where b.acct_item_type_id=a.acct_item_type_id(+)
group by b.name
我这里试就是可以的,没有的用0补充
select dq,val(count(tel),0) from smsout where dt<=sysdate and dt>sysdate-1 group by dq
统计出来某些地区的手机号数量应该为0,但显示为空,并且该地区号也不显示.这是什么原因?这是因为没有满足条件dt<=sysdate and dt>sysdate-1的该地区记录。后面的SQL也是一样。除非你把它改写为select a.dq,nvl(count(b.tel),0) from area a,(select * from smsout where dt<=sysdate and dt>sysdate-1) b
where a.dq=b.dq(+) group by a.dq