本文介绍了解释SQL Server查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下解决方案是要从Employee表中获得第六高的工资,

The following solution is for getting 6th highest salary from Employee table ,

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary


在上面的查询中," a"


In above query what is the meaning of ''a''

推荐答案

SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC as  a

-- The result of above query is assigned to 'a' and then the 'a' is queried as shown below.

SELECT TOP 1 salary
FROM a
ORDER BY salary


select t.name from (select * from tablename) as t


select * from tbl a.



这里的"a"是表tbl的别名...
像这样,"a"是查询的别名



here ''a'' is an alias for table tbl...
Like this ''a'' is an alias for the query

SELECT DISTINCT TOP 6 salary
FROM employee
ORDER BY salary DESC



您可以为别名设置任何名称.



You can set any name to the alias.


这篇关于解释SQL Server查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 21:47