代码改变世界

待查

2014-12-23 19:17  wangduqiang  阅读(114)  评论(0编辑  收藏  举报

查出一个水电标示为水电且节点类型为班组的层次下的水的层次个数,电的层次个数,水电的层次的个数
最后的结果是这样的:
select c1.mc, (select count(*) from c_zzcc c2 where c2.qxm like c1.qxm||'%') zong ,
              (select count(*) from  c_zzcc c3 where c3.qxm like c1.qxm||'%' and c3.sdbs = '水') shui,
              (select count(*) from  c_zzcc c3 where c3.qxm like c1.qxm||'%' and c3.sdbs = '电') dian ,
              (select count(*) from  c_zzcc c3 where c3.qxm like c1.qxm||'%' and c3.sdbs = '水电') shuidian
  from c_zzcc c1
  where
    c1.sdbs  = '水电'
    and c1.jdlx = '00141009102610109001'

反正我是没写出来. 这不是子查询吧. 待我查查