Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


I Have Employee table having column name as ID,SALARY
how to get second max salary from employee table with id
ex
ID SALARY
1 20000
7 37000
2 5000

Answers were Sorted based on User's Feedback



I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / belson gnana pradeep

Select Top 1 salary from (Select TOP 2 salary from tbl_salary order by salary desc)a order by salary

Is This Answer Correct ?    1 Yes 0 No

I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / ankit nanda

select [Salary],ID from (select [Salary], ROW_NUMBER() over
(order by Employee.SALARY desc)RowNum from [Employee])e
where e.RowNum=2

Is This Answer Correct ?    1 Yes 0 No

I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / sudip mondal

select top 1 from employee where ID in (select top2 ID from
employee order by Salary desc) order by Salary asc

Is This Answer Correct ?    0 Yes 0 No

I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / radhakrishnan vaithilingam

SELECT TOP 1 id.salary
FROM (SELECT TOP 2 id,salary
FROM employee
ORDER BY salary DESC )a
ORDER BY a.salary ASC

Is This Answer Correct ?    0 Yes 0 No

I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / bennison terry

Select Top 1 * from Tbl_Salary where ID not in (Select top 1 ID from tbl_salary order by salary desc) order by Id desc

Is This Answer Correct ?    0 Yes 0 No

I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / ankit nanda

Do onething
just create a function which use the three input parameters
and
while select * from ComputeEmployee(,,,)insert one of the
designation or salary or department at a time or wtever u
want....here i used some case statement to solve the
problem..wheeeeww...one thing else uniqueidentifier i just
use for the column type,u can use a simple int also ::))


create function ComputeEmployee(@Designation nvarchar
(100),@Department nvarchar(100),@Salary bigint)
returns @DemoTable table (EmployeeID
uniqueidentifier,Designation Nvarchar(100),Name Nvarchar
(100),Department Nvarchar(100),Salary bigint)
as
begin
insert into @DemoTable
select
ed.EmployeeID,ed.Designation,ed.Name,sd.Department,sd.Salary
from EmployeeDetails ed inner join
SalaryDetails sd on sd.SalaryID=ed.EmployeeID
where ed.Designation like case when
@Designation IS not null then '%'+@Designation+'%' end
AND sd.Department like case when
@Department IS not null then '%'+@Department+'%' end
AND sd.Salary =case when @Salary Is not
null then @Salary else sd.Salary end
return
end

Is This Answer Correct ?    0 Yes 0 No

I Have Employee table having column name as ID,SALARY how to get second max salary from employee ta..

Answer / bhagya

select * from emp as e1 where 1= (select count(*)from emp
as e2 where e1.sal<e2.sal)

Is This Answer Correct ?    9 Yes 11 No

Post New Answer

More SQL Server Interview Questions

Which tcl commands are available on the sql server?

0 Answers  


What is advantage data architect?

0 Answers  


Mention the differences between sql server and mysql.

0 Answers  


In my application I have a process which picks the scanned files (tif format) from a shared location and it links to application and shown on it.The actuall issue is that my process picks the file before it is completly written or scanned which results in displaying few parts of the image or incomplete image.I need to check if the file is not completly scanned or written then do not link it to application.Please help if any body tell me that how can i check that file is in written phase or locked through DTS.thanking you in advance

0 Answers  


what is Equity join?

2 Answers   ADP,


What is a table called, if it has neither cluster nor non-cluster index? What is it used for?

0 Answers  


What is database normalization?

7 Answers   Deloitte, Digicel, JPMorgan Chase, Verifone,


create index a on employee(dno) In this,which index was created?

2 Answers  


what is the Surrogate key?and wt is the diff between Primary key and Surrogate Key?

2 Answers  


what are the main differences between ms access and sqlserver

1 Answers   C DAC, CDAC,


What are null values in ms sql server?

0 Answers  


What is transaction server distributed transaction?

0 Answers  


Categories