With语句可以在查询中做成一个临时表/View,用意是在接下来的SQL中重用,而不需再写一遍。
With Clause方法的优点: 增加了SQL的易读性,如果构造了多个子查询,结构会更清晰。
示例:
with soloemp as (select distinct salary from hy_emp) select avg(salary) from (select dense_rank() over (order by salary) as seq, dense_rank() over (order by salary desc) as revseq,salary from soloemp) a where abs(a.seq-a.revseq)<=1
参考网页:https://www.cnblogs.com/mingforyou/p/8295239.html
--2020-04-14--