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
hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.
what is datawarehouse?
Determine when an index is appropriate?
What is the fastest way to permanently delete a 1 million row table named customers?
What are the system database in sql server 2005?
Can foreign key be duplicate?
what are candidate key, alternate key and composite key? : Sql server database administration
System variable and temporary variables
do you know how to configure db2 side of the application? : Sql server database administration
How to create a stored procedure with a statement block in ms sql server?
What is the command used to check locks in microsoft sql server?
How to create a user name in a database?
How to identify current user in ssrs report?
How to rename an existing table with the "sp_rename" stored procedure in ms sql server?
Define synonym?