在Have子句中使用MIN函数 [英] Using the MIN function in the having clause

查看:286
本文介绍了在Have子句中使用MIN函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道最低薪水的雇员的名字.有一种方法可以仅使用一个查询来执行此操作吗?我在下面给出了我的查询,该查询不起作用,因为hading子句需要一个条件.有什么办法可以在hading子句中给出一个条件,以最低的工资重新获得员工的姓名吗?

I want to get the name of the employee who has the minimum salary. Is there a way to do this using only one query? I have given my query below, it doesn't work because the having clause requires a condition. Is there any way to give a condition in the having clause that will retreive the employee name with the minimum salary?

SELECT first_name,min(salary) as "sal"
FROM Employees
GROUP BY first_name 
having min(salary);

推荐答案

如何使用ROWNUM?

SELECT *
FROM(SELECT first_name, salary
     FROM Employees
     ORDER BY salary
) WHERE ROWNUM = 1

这篇关于在Have子句中使用MIN函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆