ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Write sql a query to display the result 3rd maximum salary.

user-image
تم إضافة السؤال من قبل neha m
تاريخ النشر: 2016/08/31
Nivya P J
من قبل Nivya P J , Software Engineer , Essel SWolutions Pvt Ltd

SELECT TOP1 salary FROM  (SELECT TOP3 salary FROM Table_Name ORDER BY salary DESC) AS Q ORDER BY salary ASC

مستخدم محذوف‎
من قبل مستخدم محذوف‎

select top 1 salary from

(select distinct top 3 salary form table_name

order by salary )

result

order by salary desc

Sayed Elshayeb
من قبل Sayed Elshayeb , senior analyst programmer , EPL House

SELECT*FROM(SELECT ROW_NUMBER()OVER(ORDERBYkeyASC)AS rownumber, <columns> FROM <tablename> )AS foo WHERE rownumber = 3

مستخدم محذوف‎
من قبل مستخدم محذوف‎

As I understood your question you can do it by using analytical functions, as example:

select n.* from(select  p.id, p.salary, rank() over (order by p.salary desc) as cn from(select 1 as id,1000 as salary union select 2,1500 union select 3,2500 union select 4,1200) as p)n where n.cn=3

Sarah Dwekat
من قبل Sarah Dwekat , Database System Developer , Integrated Technology Group (ITG)

SELECT TOP1 Sal 

FROM ( SELECT DISTINCT TOP3 Sal

            FROM Salary

           ORDER BY Sal DESC ) AS ThirdSal ORDER BY Sal

المزيد من الأسئلة المماثلة