I want to have a query in my sql which will return the result as -
我想在我的sql中有一个查询,它将返回结果。
I am having a table named employee with columns name,salary,address. The query should return the first two highest column values from the employee table.
我有一个名为employee的表,列有name、salary、address。查询应该从employee表返回前两个最高的列值。
This should be single query.
这应该是一个查询。
1 个解决方案
#1
4
If the highest column is salary
, you do this:
如果最高的一栏是薪水,你可以这样做:
select salary from employee
order by salary desc
limit 2
You would do the same for any other columns, just replace the column name in the SELECT
and in the ORDER BY
sections.
您可以对任何其他列执行相同的操作,只需在SELECT和ORDER BY节中替换列名。
#1
4
If the highest column is salary
, you do this:
如果最高的一栏是薪水,你可以这样做:
select salary from employee
order by salary desc
limit 2
You would do the same for any other columns, just replace the column name in the SELECT
and in the ORDER BY
sections.
您可以对任何其他列执行相同的操作,只需在SELECT和ORDER BY节中替换列名。