select whse,
user_id,
shift,
tran_nbr,
to_char(sched_start_date, 'HH24:MI:SS') as STRTUP,
to_char(sched_start_date, 'MM/DD/YYYY') as DATE1,
act_name,
dept_code,
num
from (
select whse,
user_id,
shift,
tran_nbr,
sched_start_date,
to_char(sched_start_date, 'MM/DD/YYYY'),
actl_time,
act_name,
dept_Code,
dense_RANK() over (
partition by to_char(sched_start_date, 'MM/DD/YYYY'),
user_id order by user_id,
sched_start_date asc
) num
from my_hdr
) X
where to_char(sched_start_date, 'MM/DD/YYYY HH24:MM:SS') between '02/09/2017 04:00:00' and '02/09/2017 10:00:00'
and actl_time > '0'
and ACT_NAME = 'JFSTRTUP'
order by whse,
user_id,
to_char(sched_start_date, 'HH24:MI:SS')
JFSTRTUP
每当发现给它“1”的等级(数量)时,我都会尝试返回。现在我得到一些JFSTRTUP
地方num <> 1
SQL 输出:
WHSE USER_ID Shift TRAN NBR STRTUP DATE1 ACT_NAME DEPT_CODE NUM
008 AMANY 1B 900197641 05:28:00 02/09/2017 JFSTRTUP ORDERFILL 1
008 BTORR 1C 900197629 05:58:00 02/09/2017 JFSTRTUP ORDERFILL 3
008 CROM 1B 900197644 05:29:00 02/09/2017 JFSTRTUP ORDERFILL 1
我想让第二行返回 1 而不是 3。