我已经在下面的SQL中添加了一个timestamp语句,但是没有将其添加到表中。
with cx(seq, user_id, mod_date_time, menu_optn_name) as (
select 1, 'U1', timestamp '2007-05-21 16:00:00', 'O1' from dual),
cc(seq, user_id, mod_date_time, menu_optn_name) as (
select seq, user_id, cast(mod_date_time as date), menu_optn_name from cx)
select
user_id, MENU_OPTN_NAME, MOD_DATE_TIME,
case
when MOD_DATE_TIME > prior MOD_DATE_TIME+(1/96) and user_id = prior user_id then round((MOD_DATE_TIME - prior MOD_DATE_TIME)*1440,2)
else null
end as TIME_GAP
from
(select
ptt.user_id, MENU_OPTN_NAME, ptt.MOD_DATE_TIME,
row_number() over (partition by ptt.user_id order by ptt.MOD_DATE_TIME) seq
from PROD_TRKG_TRAN ptt
join cd_master cm on
ptt.cd_master_id = cm.cd_master_id
Where
MENU_OPTN_NAME = 'Cycle Cnt {Reserve}' --CHANGE BASED ON WHAT YOUR TRACKING... MENU NAMES AT THE BOTTOM
and ptt.user_id = 'SCOUNCIL' --CHANGE BASED ON WHO YOU WANT TO TRACK FOR A GAP...
and cm.cd_master_id =
(select cd_master_id
from cd_master
where
co = '&CO'
and div = '&DIV')
and ptt.create_date_time >=
/*Today*/ trunc(sysdate)
--/*This Week*/ trunc(sysdate-(to_char(sysdate,'D')-1))
--/*This Month*/ trunc(sysdate)-(to_char(sysdate,'DD')-1)
--/*Date Range*/ '&FromDate' and ptt.create_date_time-1 < '&ToDate'
--group by ptt.user_id
)cc
CONNECT BY
user_id = prior user_id
and seq = prior seq+1
start with
seq = 1
我有一个查询要向我显示时间间隔大于15的任何内容,它将告诉我该间隔有多长时间,但是我希望它能够说明班次开始的时间是4PM,所以如果他们在4pm开始工作,直到4:41 PM才在系统中执行任何操作,然后有41分钟的间隔。 不知道我做错了什么...我将时间戳部分单独构建,然后将其放入查询中,这可能不意味着要与查询一起使用,应单独使用。 感谢您对此问题的任何见解。