查詢
某一段時間,a在小於五秒鐘內出現2次以上
with t as (
select t.a,t.b
from c_table t
where 1 = 1
and b>= to_date('2012-5-29 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
and b<= to_date('2012-5-30 00:00:00', 'yyyy-mm-dd hh24:mi:ss') and t.a>'0' order by t.a
)select t.* from t where exists(
select 1 from t a where t.a=a.a and
abs(t.b-a.b)<=5/(24*60*60) and abs(t.b-a.b)>0
)--表資訊
連鎖店編號 會員卡號 錄入員工號 錄入終端 錄入時間
2012001001 12345678 2012000001 00000001 20120510 16:29:23
2012001001 12345678 2012000001 00000001 20120510 16:30:44
2012001001 12345678 2012000001 00000001 20120510 16:39:12
2012001004 12345678 2012000002 00000001 20120510 16:41:21
2012001004 32345678 2012000002 00000002 20120510 16:43:56
2012001004 22345678 2012000002 00000001 20120510 16:46:49
2012001004 52345678 2012000002 00000002 20120510 16:47:23
2012001001 32345678 2012000003 00000001 20120510 16:49:10
2012001002 82345678 2012000003 00000002 20120510 16:53:08
2012001004 92345678 2012000003 00000003 20120510 16:57:00
2012001005 92345678 2012000003 00000002 20120510 17:01:51
2012001003 82345678 2012000003 00000003 20120510 17:02:23
查詢同一連鎖店當日同一會員卡號,在相同的終端連續2次以上(含2次)錄入時間=<2分鐘
with t as (
select
'2012001001' a,'12345678' b,'2012000001' c,'1' d,to_date('20120510162923','yyyymmddhh24miss') e from dual union all select
'2012001001','12345678','2012000001','1',to_date('20120510163044','yyyymmddhh24miss') from dual union all select
'2012001001','12345678','2012000001','1',to_date('20120510163912','yyyymmddhh24miss')from dual union all select
'2012001004','12345678','2012000002','1',to_date('20120510164121','yyyymmddhh24miss')from dual union all select
'2012001004','32345678','2012000002','2',to_date('20120510164356','yyyymmddhh24miss')from dual union all select
'2012001004','22345678','2012000002','1',to_date('20120510164649','yyyymmddhh24miss')from dual union all select
'2012001004','52345678','2012000002','2',to_date('20120510164723','yyyymmddhh24miss')from dual union all select
'2012001001','32345678','2012000003','1',to_date('20120510164910','yyyymmddhh24miss')from dual union all select
'2012001002','82345678','2012000003','2',to_date('20120510165308','yyyymmddhh24miss')from dual union all select
'2012001004','92345678','2012000003','3',to_date('20120510165700','yyyymmddhh24miss')from dual union all select
'2012001005','92345678','2012000003','2',to_date('20120510170151','yyyymmddhh24miss')from dual union all select
'2012001003','82345678','2012000003','3',to_date('20120510170223','yyyymmddhh24miss') from dual
)select t.* from t where exists(
select 1 from t a where t.a=a.a and t.b=a.b and t.d= a.d
and abs(t.e-a.e)<=2/(24*60) and abs(t.e-a.e)>0
)---------------------------------
2012001001 12345678 2012000001 1 2012-5-10 16:29:23
2012001001 12345678 2012000001 1 2012-5-10 16:30:44
/*oracle 時間相減為天數:
select( to_date('20120510162923','yyyymmddhh24miss') - to_date('20120510163044','yyyymmddhh24miss'))*24 *60 *60 from dual
結果為天數:-0.0009375 天
化為分鐘:-0.0009375 * 24 *60 = -1.35 分鐘
化為秒:-1.35 分鐘= -1.35 * 60 = -81秒
*/
查詢某一段時間,a在小於五秒鐘內出現2次以上
查詢某一段時間,a在小於五秒鐘內出現2次以上 查詢 某一段時間,a在小於五秒鐘內出現2次以上 www.2cto.com with t as select t.a,t.b from c table t where 1 1 and b to date 2012 5 29 00 00 00 yyyy mm...
在Qt中程式休眠一段時間
是qthread 下的三個靜態函式 static void qthread sleep unsigned long secs 秒 static void qthread msleep unsigned long msecs 毫秒 static void qthread usleep unsigned...
按某一段時間,自動生成員工的打卡記錄
好久沒上bbs.54master了。有一朋友問了一條有關通過sql語句自動生成打卡問題。原問題 姓名 第一次打卡時間 第二次打卡時間 日期 a 8 01 17 01 07 01 01 b 8 04 17 02 07 01 01 a 8 03 17 07 07 01 02 我要做乙份假的考勤記錄,需批...