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)
 SQL Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-18 : 07:12:57
Chetan Kelkar writes "Hello,

This might sound a little lowjack question to you guys, regret it.

I have a table like this with some data in it.

-------------------------------
Sr. No. | Company | Locations |
-------------------------------
1. | Wipro | USA
2. | Wipro | UK
3. | Wipro | India
4. | NMC | India
5. | NMC | Australia
6. | Infosys | USA
7. | Infosys | UK
8. | Infosys | Germany
9. | NMC | Germany
10. | Aztec Consultings | Germany

What I would like to find out is the company and the number of locations they are present where the number of locations is greater than one. For ex. the results retrieved should be like this -->

-------------------------------
Company | Number of Locations
-------------------------------
1. Wipro | 3
2. NMC | 3
3. Infosys | 3
-------------------------------

It shouldnt count the companies which are present only at one locations.

Your help will be highly appreciated.
Thanks in advance,

Chetan Kelkar"

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2005-04-18 : 07:31:31
[code]
select company,count(*)
from t
group by company
having count(*) > 1
[/code]
Go to Top of Page
   

- Advertisement -