Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 my question

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-14 : 08:52:41
karuna writes "I have one table as described below.I want a single sql query which has all the EmpId which has maximum no of count of phoneId.For example from the below table phoneId 1 has maximum count of 3.so EmpId corresponding to PhoneId 1.Please reply soon,its very urgent.

EmpId PhoneId
1 1
2 1
3 2
4 3
5 1
6 2
7 6
8 3
9 4
10 5"

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-07-14 : 08:58:49
So do u want EmpIDs --> 1, 2 & 5 ?

Srinika
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-14 : 09:09:07
Select * from table where PhoneId in (select top 1 phoneId from table group by PhoneId order by count(*) DESC)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -