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

Explain sql delete command?

602


How can you list all the table constraints in a database?

505


What protocol does sql server use?

513


Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

514


How to create a new schema in a database?

549






Explain about Normalization?

563


What is check constraint in sql server?

521


List out different types of normalizations in sql server and explain each of them?

550


What is cte (common table expression)?

593


What happens when the SQL Azure database reaches Max Size?

90


What are the differences between stored procedure and the dynamic sql?

573


What are “unrepeatable reads”?

738


What are scalar functions in sql?

603


How does a profiler work?

512


A user is a member of the public role and the sales role. The public role has select permission on all the tables. The sales role does not have select permission on some of the tables will the user be able to select from all tables?

518