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
 SQL Server Development (2000)
 SQL Selection in VB

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-17 : 10:00:38
Nathan writes "Hi SQL team..Here's my question.
I have two multiple selection listbox in my form. So the user will give me two list of data. One is a list of cities and other is a list of employer types. I want to be able to select the number of employers for all cities selected for each employer type selected.

For example:

Cities selected: Boston, Los Angeles, New York
Employer Type selected: IT, Hardware, Software

I need: IT (15 employers), Hardware (25 employers), etc.

My tables:

Employers
EmployerId, Name, City

EmployersWithType
EmployerId, TypeId

EmployerTypes
TypeId, Type

Thanks a lot for your hlep.
Nathan"

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-07-17 : 11:08:24
select et.type, count(1) as total_employers
from employertypes et inner join employerswithtype ewt on et.typeID = ewt.type_ID
inner join employers e on ewt.employerID = e.employerID
group by et.type

That will find counts for all. For certain employer types include a where statment before the group by

where et.type in ('IT, Hardware, Software') and e.city in('Boston, Los Angeles, New York ')


I haven't had a chance to test it... So post up here the results when you try it



-----------------------
Take my advice, I dare ya
Go to Top of Page
   

- Advertisement -