解决惠安惠达Bug:待命车数量明细不对

描述:待命车数量为168-7=161,而明细中加起来是168,数量不对


以前我写的SQL:


select m.item_name hostVehType, count(m.item_name) hostVehTypeCount from
(select cc.hostid,
	cc.HOST_VEH_TYPE,
	cc.owner_appsysid,
	cc.owner_appdeptid,a.item_name
from (select ext.hostid,ext.HOST_VEH_TYPE,ext.owner_appsysid,ext.owner_appdeptid
	   from position_host_info p
	   left join position_host_info_extend ext
		 on p.hostid = ext.hostid
	  where ext.verify_status = 1
		and (ext.process_status <3)) cc,
	DICTIONARY_ITEM a
where a.dic_type = 'HOST_VEH_TYPE' and cc.HOST_VEH_TYPE = a.item_value
and ((cc.owner_appsysid, cc.owner_appdeptid) in
		   (select appsysid, appdeptid
			   from table(get_subdept(-1, 2000, 0)))) )m  group by m.item_name

加起来的数量为168,是总的数量,并不是待命车的数量啊

修改SQL如下:测试待命车的数量为161,正确!


select m.item_name hostVehType, count(m.item_name) hostVehTypeCount from
(select cc.hostid,
    cc.HOST_VEH_TYPE,
    cc.owner_appsysid,
    cc.owner_appdeptid,a.item_name
from (select ext.hostid,ext.HOST_VEH_TYPE,ext.owner_appsysid,ext.owner_appdeptid
       from position_host_info p
       left join position_host_info_extend ext
         on p.hostid = ext.hostid
      where ext.verify_status = 1 --审核状态:0-未审核,1-已审核
        and (ext.process_status <3)) cc,--车辆处理状态:1-正常;2-处置中;3-报废中;4-已处置;5-已报废
    DICTIONARY_ITEM a
where a.dic_type = 'HOST_VEH_TYPE' and cc.HOST_VEH_TYPE = a.item_value
and  cc.hostid not in--过滤任务车数量
(select tt.host_id
      from (SELECT t.host_id
              FROM vd_veh_assign_list t
              LEFT JOIN position_host_info_extend ext
                ON t.host_id = ext.hostid
             WHERE t.execute_status = 1--派车单执行状态:0未执行;1执行中;2执行完成
               and ext.PROCESS_STATUS < 3
               AND ((ext.owner_appsysid, ext.owner_appdeptid) in
                   (select appsysid, appdeptid
                       from table(get_myviewdeptlist(1, 2000, 0))))) tt) 
and ((cc.owner_appsysid, cc.owner_appdeptid) in
           (select appsysid, appdeptid
               from table(get_subdept(-1, 2000, 0)))) )m  group by m.item_name

因为我们发现任务车的SQL是这样的,有了灵感,在总的数量中通过hostid把任务车过滤掉,想到了这一点,其实很简单



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZHOU_VIP

您的鼓励将是我创作最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值