作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Presto SQL 真的缺少 SELECT 语句中的 TOP X 功能吗?
如果是这样,在此期间是否有解决方法?
https://prestodb.io/
最佳答案
如果只是想限制结果集中的行数,可以使用 LIMIT
, 有或没有 ORDER BY
:
SELECT department, salary
FROM employees
ORDER BY salary DESC
LIMIT 10
row_number()
窗函数。例如,要按工资获得每个部门的前 3 名员工:
SELECT department, salary
FROM (
SELECT department, salary row_number() OVER (
PARTITION BY department
ORDER BY salary DESC) AS rn
FROM employees
)
WHERE rn <= 3
关于sql - 在 Presto SQL 中选择 Top #?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37667265/
我是一名优秀的程序员,十分优秀!