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...

Find 2nd Highest salery in emp table

Select* from emp where &n=
select * count from emp where (salery >=emp.salery)


Enter n value 2


These query is correct or not. Tell me any other methods.

Answer Posted / madhu sudhan g

Hii lets consider the table Salary having EMPNO,EMPSal columns
to find the 2nd higest salary

;WITH CTE(Sal,Row)
AS
(
select EMPSal,ROW_NUMBER() OVER(ORDER BY EMPSal) as Row from Salary
)
select sal as Salary from CTE where Row=2

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to provide default values to stored procedure parameters?

1039


Why is there a performance difference between two similar queries where one uses union and the other uses union all?

1014


What should be the fill factor for indexes created on tables? : sql server database administration

1119


Can a trigger be created on a view?

936


What is explicit mode in sql server?

1042


Mention the differences between local and global temporary tables.

1003


What is the full meaning of dml?

934


What is the maximum size of sql server database?

987


what are cursors? : Sql server database administration

1038


How many database files are there in sql server 2000?what are they?

1026


What does truncate do?

920


How to insert a new row into a table with "insert into" statements in ms sql server?

950


Explain cdc and sql injection?

956


What are views used for?

992


Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?

936