--本网发送秒峰值
SELECT *
FROM (SELECT monthday,
tc,
ct,
dense_rank() over(PARTITION BY monthday ORDER BY ct DESC)
orderid
FROM (SELECT t.monthday,
to_char(t.insertime, 'yyyy-mm-dd hh24:mi:ss') tc,
COUNT(1) ct
FROM t_dz_msa_mediasend_his t
WHERE t.monthday LIKE '11__'
AND
t.sendtime > trunc(SYSDATE, 'yy')
AND t.sendno LIKE '010%'
GROUP BY t.monthday,
to_char(t.insertime, 'yyyy-mm-dd hh24:mi:ss')
ORDER BY ct DESC))
WHERE ORDERid <=1
按业务按日期,分钟峰值
SELECT *
FROM (SELECT monthday,
serviceid,
tc,
ct,
dense_rank() over(PARTITION BY monthday,serviceid ORDER BY ct DESC)
orderid
FROM (SELECT t.monthday,t.serviceid,
to_char(t.insertime, 'yyyy-mm-dd hh24:mi') tc,
COUNT(1) ct
FROM t_dz_msa_mediasend_his t
WHERE t.monthday = '0109'
AND
t.sendtime > trunc(SYSDATE, 'yy')
GROUP BY t.monthday,t.serviceid,
to_char(t.insertime, 'yyyy-mm-dd hh24:mi')
ORDER BY ct DESC))
WHERE ORDERid <=1
查询出学生中成绩第三的所有人信息
select *
from t_student a
where exists (select id from (select id,
dense_rank() over(order by sum(score) desc) rnum
from t_student t
group by id)
where rnum = 3
and a.id = id)
select *
from t_student
where score = (select score
from (select tt.*, rownum rn
from (select distinct (t.score)
from t_student t
order by to_number(t.score) desc) tt)
where rn = 3)