want one sql query...
-
hi to all.... i have no so much experience in sql. one query i want may be its simple but still i want it. if there is table "EmpTbl" with fields empid,empname and salary. Then how i find the second max salary and second last salary of the Employee??? plz help me out ... thanks
-
hi to all.... i have no so much experience in sql. one query i want may be its simple but still i want it. if there is table "EmpTbl" with fields empid,empname and salary. Then how i find the second max salary and second last salary of the Employee??? plz help me out ... thanks
You'll get a lot of results if you search on google anyways.. Here the queries.. For second max.
select MAX(salary) from EmpTbl where salary < (select MAX(salary) from EmpTbl)
and For second min
select Min(salary) from EmpTbl where salary > (select MIN(salary) from EmpTbl)
Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0
-
hi to all.... i have no so much experience in sql. one query i want may be its simple but still i want it. if there is table "EmpTbl" with fields empid,empname and salary. Then how i find the second max salary and second last salary of the Employee??? plz help me out ... thanks
Here is one I did for freight_cost: You will need the second example. -- max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost -- 2nd max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost WHERE Freight_Cost NOT IN (SELECT MAX(Freight_Cost) FROM Product_Freight_Cost)
-
You'll get a lot of results if you search on google anyways.. Here the queries.. For second max.
select MAX(salary) from EmpTbl where salary < (select MAX(salary) from EmpTbl)
and For second min
select Min(salary) from EmpTbl where salary > (select MIN(salary) from EmpTbl)
Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0
thanks a lot ok from this i will search on google instead of asking in forum.. but thanks a lot .....
-
Here is one I did for freight_cost: You will need the second example. -- max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost -- 2nd max cost SELECT MAX(Freight_Cost) FROM Product_Freight_Cost WHERE Freight_Cost NOT IN (SELECT MAX(Freight_Cost) FROM Product_Freight_Cost)
thanks a lot...