Oracle 算出来的数据 0省去了 求原因
小小崔同学 2019-09-06 03:03:16
SELECT decode(b.计划趟次, 0, 0, round(a.完成车次 / b.计划趟次, 4))车次完成率
from (select sum(fd.seqnum) 完成车次
from FDISDISPLANLD fd
where fd.routeid = '80001'
and fd.isactive = 1
and (fd.isconfirm = 1 or fd.recstate in (5, 24, 10))
and fd.rectype = '1'
and fd.rundate = trunc(sysdate)) a,
(select sum((f.overtime - f.begintime) * 24 * 60 / intervaltime) + 1 计划趟次,
f.rundate
from fdisdispatchinterval f
where exists (select 1
from mcsegmentinfogs
where segmentid = f.segmentid
and rundirection = '1')
and f.routeid = '80001'
and f.rundate = trunc(sysdate)
) b
这段sql的执行结果是 0.5
SELECT decode(b.计划趟次, '0', '0', round(a.完成车次 / b.计划趟次, 4))车次完成率
from (select sum(fd.seqnum) 完成车次
from FDISDISPLANLD fd
where fd.routeid = '80001'
and fd.isactive = 1
and (fd.isconfirm = 1 or fd.recstate in (5, 24, 10))
and fd.rectype = '1'
and fd.rundate = trunc(sysdate)) a,
(select sum((f.overtime - f.begintime) * 24 * 60 / intervaltime) + 1 计划趟次,
f.rundate
from fdisdispatchinterval f
where exists (select 1
from mcsegmentinfogs
where segmentid = f.segmentid
and rundirection = '1')
and f.routeid = '80001'
and f.rundate = trunc(sysdate)
) b
这段sql 的执行结果是.5 他俩的区别是第一个0每家单引号,第二个加了单引号 求oracle大佬 告诉我这是什么原因