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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List out what other servers you can use with ssrs?

130


Which is the main third-party tool used in sql server?

880


Which data type columns are the best candidates for full-text indexing?

916


What is a non clustered primary key?

871


What is Replication?

988


How to concatenate two binary strings together?

1047


Why is replication required on the sql server?

1006


Explain about sql server login?

1021


How to return the top 5 rows from a select query in ms sql server?

1070


Do you know sql server 2008 introduces automatic auditing?

901


 Explain what is sql override for a source taLle in a mapping?

942


How to create a simple table to test triggers in ms sql server?

909


what is the difference between delete table and truncate table commands? : Sql server database administration

958


Can an automatic recovery be initiated by a user?

941


can you implement data mining in SSRS?

138