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


two tables are there.1st table EMP has two columns ID and name and contains data 1,A
2,B
3,C
2nd table EmpSal has 2 columns ID and Salary
Contains data -1,1000
2,5000
3,3000

Find name of employee having maximum salary ?

Answers were Sorted based on User's Feedback



two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd ..

Answer / gajula.lavanya

SELECT T1.NAME,T2.SAL FROM emp1 T1,emp2 T2
WHERE T1.ID=T2.ID AND T2.SAL=(SELECT MAX(SAL) FROM emp2);

Is This Answer Correct ?    1 Yes 0 No

two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd ..

Answer / ramnath_445

SELECT name,min(sal) from emp1 inner join empsal where emp1.id=empsal.id

Is This Answer Correct ?    2 Yes 2 No

two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd ..

Answer / kanagavel

with cte
as
(
SELECT name,max(sal) as 'sal'
from emp1 inner join empsal
where emp1.id=empsal.id
group by name
)
select top 1 *
from cte
order by sal desc

Is This Answer Correct ?    0 Yes 0 No

two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd ..

Answer / b.kumar

--BY USING MS SQL SERVER

SELECT TOP 1 * FROM
(SELECT DISTINCT TOP 1 #A.ID,#A.NAME,#B.SAL
FROM #A INNER JOIN #B ON #A.ID=#B.ID ORDER BY SAL) E
ORDER BY SAL

--HERE #A, #B ARE TEMP TABLES
--E IS ALIAS NAME

Is This Answer Correct ?    0 Yes 0 No

two tables are there.1st table EMP has two columns ID and name and contains data 1,A 2,B 3,C 2nd ..

Answer / ganesh

with cte as
(
select *,row_number() over(order by salary desc) as rowno
from empsal
)
select * from emp e join cte c
on e.id=c.id
where c.rowno=1

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More SQL Server Interview Questions

What is a data collection table?

0 Answers  


Can we call stored procedure in trigger?

0 Answers  


Relational calculus is what type of language?

0 Answers   HCL,


Please explain that what are the basic functions for master, msdb, model, tempdb and resource databases? : SQL Server Architecture

0 Answers  


How to write character string constants or literals in ms sql server?

0 Answers  


code to create procedure for taking databse backup in sql server or i have the query for it but what it's query returns means i want to show on my jsp that the databse backup has been taken on the basis of that return value.does it returns 0 or 1.wat is the code for that

0 Answers   IGT,


What are sql servers used for?

0 Answers  


What is field with example?

0 Answers  


hi i am having .mdf file and .ldf file ..how can i get the all table in my .mdf..plz give solution

2 Answers  


What is de-normalization and what are some of the examples of it?

0 Answers  


What is the difference between mysql and sql server?

0 Answers  


What is the purpose of floor function?

0 Answers  


Categories