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 Posted / anil panwar

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible for a stored procedure to call itself or recursive stored procedure?

508


How to scale out a federation by Sql statement?

92


Can we write trigger for view?

557


Can we perform backup restore operation on tempdb? : sql server database administration

584


Explain the truncate command?

522






Explain can you implement data mining in ssrs?

106


What is the difference between inner join and equi join?

492


What does the not null constraint do?

581


What is awe?

569


Explain system rowset functions?

558


What is the use of toad or sqldbx.?

723


What is the difference between substr and charindex in the sql server?

510


explain declarative management framework (dmf) in sql server 2008?

583


John exports information periodically from a microsoft sql server database to an oracle database what is the best way to do this?

532


Explain concepts of analysis services?

513