can any one answer this query,thank you in advance
Table 1 has 2 columns: EmployeeId, T shirtsize(values can
be 1,2,3)
Table 2 has 2 columns: EmployeeId, Region
Write SQL to Find the region which has the largest number
of people with Tshirt size=3
Answer Posted / ramesh babu
Create table #temptshirt(empid int,tshirt int)
Create table #tempregion(empid int,region varchar(200))
Insert into #temptshirt(empid,tshirt)values(100,2),(102,4),
(103,5),(104,3),(105,3),(106,3),(107,5),(108,6),(109,3),
(110,4),(111,3)
Insert into #tempregion(empid,region)values(100,'SA'),
(102,'SA'),(103,'UK'),(104,'UK'),(105,'PHL'),(106,'US'),
(107,'US'),(108,'US'),(109,'RSA'),(110,'RSA'),(111,'UK')
Select Top 1 T.region,T.Total
from
(
Select b.region,COUNT(*)[Total] from #temptshirt a inner
join #tempregion b on a.empid=b.empid
Where a.tshirt=3
group by b.region
)T
order by 2 desc
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
what is denormalization and when would you go for it? : Sql server database administration
I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that
Explain different forms of normalization?
Why olap is used?
What purpose does the model database server?
What is create command?
Data is not being delivered to subscribers, what can be the possible reasons? : sql server replication
How to use subqueries with the in operators in ms sql server?
What is key attribute?
How to find the login name linked to a given user name?
What are the steps you should follow to start sql server in single-user mode?
You want to implement the one-to-one relationship while designing tables. How would you do it?
What is the standby server?
How do I uninstall sql server 2014?
What is the difference between writing data to mirrored drives versus raid5 drives