select rownum, id, name, recordDay, payDay, salesDay
from (select id, name, recordDay, payDay, salesDay
from (select id id,
max(NAME) name,
sum(RECORD_DAY) recordDay,
sum(PAY_DAY) payDay,
sum(SALES_DAY) salesDay
from diagnosis_rank_product
group by id)
order by recordDay desc)
where rownum <= 100
from (select id, name, recordDay, payDay, salesDay
from (select id id,
max(NAME) name,
sum(RECORD_DAY) recordDay,
sum(PAY_DAY) payDay,
sum(SALES_DAY) salesDay
from diagnosis_rank_product
group by id)
order by recordDay desc)
where rownum <= 100
本文介绍了一个复杂的SQL查询案例,通过多层子查询实现对诊断产品排名数据的统计汇总,并按记录天数降序排列,最终选取前100条数据。此查询涉及多表连接、聚合函数、子查询等高级SQL特性。
2974

被折叠的 条评论
为什么被折叠?



