ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
please can anyone answer this query

Table 1 has 2 columns: EmployeeId,Age
Table 2 has 2 columns:  EmployeeId, Region 
Write SQL to Find the region who has the oldest person
 Question Submitted By :: Padmavasireddy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 1
select region from table1 where employeeid in (select 
employeeid from table2 where age in (select max(age) from 
table2))
 
Is This Answer Correct ?    1 Yes 0 No
Shivaraj
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 2
select t1.id, t2.region from  table t1 left outer Join table2 t2
on t1.id=t2.id 
where t1.id in (select id from table1 where age=(select
max(age) from table1))
 
Is This Answer Correct ?    0 Yes 1 No
Anil Panwar
 
 
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 3
Hi  Shivaraj 
the ans you have given that is correct but 
anyway,
if different employee id have same age and different region
and region is null in that case will not show Null region
for that employee


it may be solution....

select t1.id, t2.region from t1 left outer Join t2
on t1.id=t2.id 
where t1.id in (select id from t1 where age=(select max(age)
from t1)) group by  t1.id, t2.region
 
Is This Answer Correct ?    0 Yes 0 No
Anil Panwar
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 4
SELECT REGION,AGE, T1.EMPID FROM T2 INNER JOIN T1
ON T1.EMPID = T2.EMPID WHERE AGE = (SELECT MAX(AGE) FROM T1)
 
Is This Answer Correct ?    1 Yes 0 No
Monal
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 5
SELECT REGION FROM T2 T2 INNER JOIN
T1 T1 ON T1.EMPID = T2.EMPID INNER JOIN
(SELECT MAX(AGE) AGE FROM T1) TBLAGE ON T1.AGE = TBLAGE.AGE
 
Is This Answer Correct ?    0 Yes 0 No
Monal
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 6
select ID, region from tab1 where ID in
(select ID from tab2 where isnull(age,0)=(select max(age)
from tab2))
 
Is This Answer Correct ?    0 Yes 0 No
Devendra Sharma
 
  Re: please can anyone answer this query Table 1 has 2 columns: EmployeeId,Age Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region who has the oldest person
Answer
# 7
select e.empid,e2.region from empAge1 e,empAge2 e2
where e.empid=e2.empid and e.age in(select max(age) from 
empAge1)
 
Is This Answer Correct ?    0 Yes 0 No
Saravanan P
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What are explicit and implicit transactions?  2
write down the sql query? Table Name : emp1 empid empname 1 bala 2 guna Table Name : emp2 empid empname 1 <Null> 2 <Null> Solution : emp1 names are updated in emp2, write a query?  7
What is cursor ? And what is difference between Trigger ? HCL1
what purpose does OPENXML clause have in sql server stored procedure?  1
How to tune a stored procedure?  5
plz tell me the new features of sqlserver2000,sqlserver2002,sqlserver2005  3
What is a Trace frag?Where can we use this?  1
What do you mean by COLLATION?  4
What is a trigger?  3
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE? Yardi-Software4
What is the system function to get the current user's user id? TCS3
what is the signification difference of this bit data type between sql 6.5 and later version sql server?  1
What is a table called, if it does not have neither Cluster nor Non-cluster Index?  1
how to connect sybase to sql server 2005?. ABC1
What is a Join in SQL Server?  2
Which command using Query Analyzer will give you the version of SQL server and operating system?  3
can you any body tell me the how to decrease the logfile  4
What is bit datatype and what's the information that can be stored inside a bit column?  1
Is it possible to have more then one foreign key in a single table? if possible, is this the good way to design the table?  2
CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType varchar(50) ) go create trigger hpms_create_Insert on HPMS_CompetencyTypes for insert as if Exists ( select * from [HPMS_CompetencyTypes] where CompetencyType=(select * from [HPMS_CompetencyTypes])) begin Rollback tran Raiserror ('duplicate value',12,6) go insert HPMS_CompetencyTypes (CompetencyType) values ('new') I'm new to trigger can any one tell me where is the issue. Please.  2
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com