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

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 / ramesh babu

Create table #tempempid(Employeeid int,age int)
Create table #tempempregion(Employeeid int,Region varchar
(200))

Insert into #tempempid(Employeeid,age)values(100,25),
(101,35),(103,35),(104,10),(105,12),(106,11),(107,13),
(108,24),(109,22),(110,17),(111,11),(112,25),(113,100) ,
(52,100)
go
Insert into #tempempregion(Employeeid,region)values
(100,'SA'),(102,'SA'),(103,'UK'),(104,'UK'),(105,'PHL'),
(106,'US'),(107,'US'),(108,'US'),(109,'RSA'),(110,'RSA'),
(111,'UK'),(113,'SA'),(52,'CA')

Select T.region,T.Age from
(
Select b.region as Region,a.age as Age,
rank() over(order by age desc) as Rnk
from #tempempid a inner join #tempempregion b on
a.Employeeid=b.Employeeid
)T
Where T.Rnk=1

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

do you know how to configure db2 side of the application? : Sql server database administration

1046


Explain about protocol layer present in SQL server?

1212


What is sql server programming?

1048


How can I check if a view exists in a sql server database?

1042


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

968


Tell me what do we need queues in sql service broker?

999


what is a schema in sql server 2005? : Sql server database administration

1034


What are the different editions available in sql server 2000?

1056


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

1000


What do you understand by sql server agent?

980


Can binary strings be converted into numeric or float data types?

1044


Describe and explain about SQL native client?

1113


How you can move data or databases between servers and databases in sql server?

1055


What are the commands used in DCL?

1029


How to delete duplicate rows?

1001