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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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 ?    0 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 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
# 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 ?    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
# 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
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
If there exist a index on the table, and we then make a view on that table (include the indexed column from base table) than why do we require indexing on view?Doesnt it create an overhead?  1
How do we get month name in SQL Server 2000, Oracle, MS Access?  4
What is a transaction and what are ACID properties?  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?  3
Difference between sql server 2000 and sql server 2005? Satyam2
i want to join two queries....and i want to run them as one after another that is want output of first query then second , then again output of first query then second and so on...  1
in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.  6
How can your resolve deadlocks? IBM3
how to rename the table  1
I have a table in which phno is one of the columns.i do have some values in tht phno column.i need to update phno column values with 0(zero) as prefix.give me a correct solution plz... Value-Labs4
Let us say master db itself has no backup. Now you have to rebuild the db so what kind of action do you take?  1
What are cursors?  7
What are the advantages of using sql server over ms access or why should one use sql instead of ms access Impetus1
syntax for deleting the database in T SQL  3
What is mean by "fill factor" ? and what is mean by "Index "in sql? Logica-CMG1
The Difference between 'Count' and 'Count(*)'  8
What is transcation?Plz give One example?  1
What are the type of joins? When do we use Outer and Self joins?  3
How to give a user the option of importing Excel and a delimited text file into a SQL Server Database without manually using SQL DTS? GE1
How to tune a stored procedure?  4
 
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