幫我希望寫在SQL Server需要使用SQL Server查詢
from (
select DISTINCT salary
from employee
order by salary desc
)
where rownum = 3;
幫我希望寫在SQL Server需要使用SQL Server查詢
from (
select DISTINCT salary
from employee
order by salary desc
)
where rownum = 3;
例如,
WITH EmployeeSalary AS
(
select salary,
ROW_NUMBER() OVER (order by salary desc) AS 'RowNumber'
FROM employee
group by salary --you can't use DISTINCT because ROW_NUMBER() makes each row distinct
)
SELECT *
FROM EmployeeSalary
WHERE RowNumber = 3;
SELECT DISTINCT salary
FROM employee
WHERE rownum = 3
ORDER BY salary
的上限是可選此查詢。 rownum是員工中的專欄,還是隻查找返回的第三行?
如果您發佈代碼,XML或數據樣本,請**在文本編輯器中突出顯示這些行,然後單擊編輯器工具欄上的「代碼示例」按鈕(「{}」)以精確地格式化和語法突出顯示它! – 2011-05-13 15:23:52
謝謝EvoD,rownum不是專欄。我在第三排 – 2011-05-13 15:26:52
感謝marc_s!看起來我們上面有一個完整的答案! – 2011-05-13 15:30:34
所以..你有什麼問題嗎? gremlins是否阻止您編寫查詢? – mellamokb 2011-05-13 15:20:02