6

请教一个比较麻烦的 Oracle 转 Mysql 的问题

 1 year ago
source link: https://www.v2ex.com/t/884184
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  MySQL

请教一个比较麻烦的 Oracle 转 Mysql 的问题

  darnurash · 5 小时 13 分钟前 · 360 次点击

有一个 oracle 的 sql 要转写成 mysql 5.7 的写法,但是有几个分析函数很麻烦:

SELECT * FROM ( SELECT s.NAME , s.SUBJECT , s.SCORES , s.TERM , ROW_NUMBER() OVER (PARTITION BY SUBJECT ORDER BY SCORES DESC NULLS LAST ) AS rn, count(*) OVER (PARTITION BY SUBJECT ) AS rr, DENSE_RANK() OVER (PARTITION BY SUBJECT ORDER BY SCORES DESC) AS rd FROM SCORES s) FF WHERE FF.rn>2 AND FF.rr>2 AND FF.rd>2

 难点就是实现 ROW_NUMBER() ... NULLS LAST)、count(*) OVER...、DENSE_RANK() OVER
 请问有什么快捷的写法么?

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK