大体的SQL文是这样的: select t.mc,count(d.*),j.mc from teqy t inner join tedp d on t.id=t.bm inner join tejz j on j.bm=t.bm group by t.mc,j.mc 你再根据你的需求将显示内容写到select中,然后将该SQL文加到存储过程中即可。 CREATE PROCE AA ... SQL文 GO
经过我冥思苦想 大概想出来一点 跟二楼的差不多(谢谢二楼) select '江西' as 省份,t3.mc as 地级市,t4.mc as 县级市,count(1) as 分线盒总数 into p_province,p_city,p_county,p_sum from tedp t1,tejz t2,tcqy t3,tczqy t4 where t4.qybm = t3.bm and t4.bm = t2.zqybm and t1.jzbm = t2.bm group by t4.mc,t3.mc 这样虽然统计出来数据 但是后面两个数据都没出来 于是我加了这一条 count( bm in (select bm from tedp where sszt in ('在用','已用','使用'))) 但是执行报错ORA-00907 missing right parenthesis
count( bm in (select bm from tedp where sszt in ('在用','已用','使用')))bm 这个能识别出来么?
select '江西' as 省份,t3.mc as 地级市,t4.mc as 县级市,count(1) as 分线盒总数 from tedp t1,tejz t2,tcqy t3,tczqy t4 where t4.qybm = t3.bm and t4.bm = t2.zqybm and t1.jzbm = t2.bm group by t4.mc,t3.mc; select '江西' as 省份,t3.mc as 地级市,t4.mc as 县级市,count(1) as 使用中分线盒数 from tedp t1,tejz t2,tcqy t3,tczqy t4 where t4.qybm = t3.bm and t4.bm = t2.zqybm and t1.jzbm = t2.bm and t1.sszt in ('在用','已用','使用') group by t4.mc,t3.mc; 最后只能这样查出两条 使用中分线盒,分线盒总数 但是使用率就没法弄了 求助高手怎么写这个存储过程
select t.mc,count(d.*),j.mc
from teqy t inner join tedp d on t.id=t.bm
inner join tejz j on j.bm=t.bm
group by t.mc,j.mc
你再根据你的需求将显示内容写到select中,然后将该SQL文加到存储过程中即可。
CREATE PROCE AA
...
SQL文
GO
select '江西' as 省份,t3.mc as 地级市,t4.mc as 县级市,count(1) as 分线盒总数
into p_province,p_city,p_county,p_sum
from tedp t1,tejz t2,tcqy t3,tczqy t4 where t4.qybm = t3.bm
and t4.bm = t2.zqybm and t1.jzbm = t2.bm group by t4.mc,t3.mc
这样虽然统计出来数据 但是后面两个数据都没出来
于是我加了这一条 count( bm in (select bm from tedp where sszt in ('在用','已用','使用'))) 但是执行报错ORA-00907 missing right parenthesis
from tedp t1,tejz t2,tcqy t3,tczqy t4 where t4.qybm = t3.bm and t4.bm = t2.zqybm
and t1.jzbm = t2.bm group by t4.mc,t3.mc; select '江西' as 省份,t3.mc as 地级市,t4.mc as 县级市,count(1) as 使用中分线盒数
from tedp t1,tejz t2,tcqy t3,tczqy t4 where t4.qybm = t3.bm and t4.bm = t2.zqybm
and t1.jzbm = t2.bm and t1.sszt in ('在用','已用','使用') group by t4.mc,t3.mc;
最后只能这样查出两条 使用中分线盒,分线盒总数 但是使用率就没法弄了
求助高手怎么写这个存储过程