--Find the schedule first
SELECT * from Hv_item_info a where a.report_begdate > ' 2016-07-28 ' and A.report_begdate < ' 2016-07-29 ';
--Search for rounds
SELECT * from Media_item_wheel_info a WHERE a.item_id = 46088 and a.rule_id = 0215 ORDER by a.begin_date;
--Key conditions
SELECT * from Media_user_dial_info a WHERE a.item_id = 46088 and a.item_wheel_id in (' 74419 ');
--Number of winners
SELECT * from Media_prizerl_info a WHERE a.item_id = 46088 and a.item_wheel_id in (' 74419 ');
--Pre-start online number
Select * FROM (
Select T.callingnbr,
T.callednbr,
T.flag,
Leads (T.flag, 1, null) over ( Partition by T.CALLINGNBR, T.CALLEDNBR Order by T.logdate) Nextflag,
T.logdate,
Leads (t.logdate, 1, null) over (part Ition by T.CALLINGNBR, T.CALLEDNBR Order by T.logdate)
from Media_user_online_offline_log T
where T.CALLEDNBR in ( ' 12590484666 ', ' 12590484667 ')
and T.flag <> ' DD '
and t.logdate >= to_date (' 20160728105000 ', ' Yyyymmddhh24miss ')
and t.logdate <= to_date (' 20160728113739 ', ' Yyyymmddhh24miss ')) a
where A.flag = ' on ' and n Extflag is null;
--The number of people online at the end
SELECT * FROM (
Select T.callingnbr,
T.CALLEDNBR,
T.flag,
Leads (T.flag, 1, NULL) over (partition by T.CALLINGNBR, T.CALLEDNBR Order by T.logdate) Nextflag,
T.logdate,
Lead (t.logdate, 1, NULL) over (partition by T.CALLINGNBR, T.CALLEDNBR ORDER by T.logdate)
From Media_user_online_offline_log t
where T.callednbr in (' 12590484666 ', ' 12590484667 ')
and T.flag <> ' DD '
and T.logdate >= to_date (' 20160728105000 ', ' Yyyymmddhh24miss ')
and T.logdate <= to_date (' 20160728113749 ', ' Yyyymmddhh24miss ')) a
where A.flag = ' on ' and Nextflag is null;
Day Grab stool Data sql