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

1. How to fetch all the duplicate records from the table.

2. How to fetch the second highest salary from the table.

Answer Posted / kunal gupta

These are the easiest and best queries and 100% tested.

1) 2nd highest salary


select top 1 sal from (Select top 2 sal from emp group by
sal order by sal desc) e order by sal


like wise you can find n highet salar(e.g 5th largest 6th
largest)

select top 1 sal from (Select top [n] sal from emp group by
sal order by sal desc) e order by sal


2) fetch all duplicated records from the table

e.g If table has three columns named 'col1', 'col2'
and 'col3'

select col1, col2, col3 from tbl group by col1, col2, col
having count(col1)>1

Is This Answer Correct ?    13 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are constraints in microsoft sql server?

1040


how many clustered indexes can be created on a table? : Sql server database administration

1068


explain what is a deadlock and what is a live lock? How will you go about resolving deadlocks? : Sql server database administration

864


what is a join and explain different types of joins? : Sql server database administration

913


What is the difference between having clause and where clause in sql server?

1033


What is a cursor, index in sql?

1017


Explain sql delete command?

1005


‘Order by’ is not allowed in a view how can you sort information from a view?

1028


Which is faster statement or preparedstatement?

894


what is difference between NULL and ISNULL in SQL Server 2008?

967


what is isolation level at dead lock?

2089


what are defaults? Is there a column to which a default can't be bound? : Sql server database administration

1069


Does partitioning help performance?

891


What is indexing in sql server with example?

926


What is the difference between Clustered and Non-Clustered Index?

1014