oracle语句两张表相减,看最后是否有误差
时间:2021-07-01 10:21:17
帮助过:18人阅读
total_seconds1,total_seconds2,total_seconds1
-total_seconds2
AS gap
from
(select (hours
+minutes
+seconds)
AS total_seconds1
from (
select
to_char(sysdate,(‘HH24‘))
*60*60 AS hours,
to_char(sysdate,(‘mi‘))
*60 AS minutes,
to_char(sysdate,‘ss‘)
AS seconds
from dual
)),
(select (hours
+minutes
+seconds)
AS total_seconds2
from (
select
to_char(sysdate,(‘HH24‘))
*60*60 AS hours,
to_char(sysdate,(‘mi‘))
*60 AS minutes,
to_char(sysdate,‘ss‘)
AS seconds
from(
select
to_char(f_quotation_time,‘HH24:mi:ss‘)
from A tq,B tc
where
tq.f_contract_id = (
select f_id
from B
where f_symbol
= ‘AG‘)
and tc.f_symbol
= ‘AG‘ )
));
解读:
解读:
AS:是给前面的结果指定一个新的列
HH21:时
mi:分
ss:秒
1,首先找出A和B的时间最后算出秒数,然后在找出两表相减,得出结果,结果gap列是新增的结果列是误差值
2,下面B和C的查询中是先找的时分秒,之后算出总秒
3,这个看着比较多,简单的方法还未找到,还有一种是直接时分秒相减但是提示ORA-01722:无效数字,然后没有找到处理方式就放弃这种了,最后用秒数相减
最后得出零误差
oracle语句两张表相减,看最后是否有误差
标签:bsp code 系统表 处理 char minutes color quota nbsp