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

select top 3 sal from each dept?

Answer Posted / neetika vardhan

SELECT DEPT, MAX(SAL)
FROM EMP
WHERE SAL NOT IN (SELECT MAX(SAL) FROM EMP GROUP BY DEPT)
GROUP BY DEPT

UNION

SELECT DEPT, MAX(SAL)
FROM EMP
GROUP BY DEPT

UNION

SELECT DEPT, MAX(SAL)
FROM EMP
WHERE SAL NOT IN
(SELECT MAX(SAL)
FROM EMP
WHERE SAL NOT IN (SELECT MAX(SAL) FROM EMP GROUP
BY DEPT)
GROUP BY DEPT

UNION

SELECT MAX(SAL) FROM EMP GROUP BY DEPT)
GROUP BY DEPT

Is This Answer Correct ?    0 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is file based approach?

877


What is the command used to fetch first 5 characters of the string?

1336


Can we write dml inside a function in sql server?

900


how to check myisam tables for errors? : Sql dba

1261


Explain mutating table error.

1132


If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????

3947


Explain how to use transactions efficiently : transact sql

926


Can we want to pass a parameter payroll_id to this external pl/sql function, how do we do it?

993


What is nvl?

1018


What are the benefits of triggers?

1122


What is a string data type in sql?

964


What are synonyms in sql?

932


what happens if null values are involved in expressions? : Sql dba

1001


Is join and inner join the same?

942


What is the difference between a query and a report?

904