首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

请问一个PL/SQL语句

2012-02-27 
请教一个PL/SQL语句表名datacount字段deliver_countsubmit_counticp_id101010005610006710002110100112101

请教一个PL/SQL语句
表名datacount
字段
deliver_count       submit_count           icp_id
10                                 10                             1000
5                                     6                             1000
6                                     7                             1000
21                                 10                             1001
12                                 10                             1001
icp_id企业ID,
sql= "select   icp_id,   sum(deliver_count)   d,sum(submit_count)   s   from   datacount   t1   group   by   icp_id ";
在以上语句的基础上,现在我想求一条语句,就是求d与s之和大于60的icp_id,并也可以查询出这个icp_id的d和s,用一条语句


[解决办法]
select * from
(select icp_id, sum(nvl(deliver_count,0)) d,sum(nvl(submit_count,0)) s
from datacount t1 group by icp_id
)
where d+s> 60
[解决办法]
select icp_id, sum(deliver_count) d,sum(submit_count) s from datacount t1
having sum(deliver_count) + sum(submit_count) > =61
group by icp_id

热点排行