I need help with a SQL statement

G

Guest

I have a table that has two fields that I want to work with. The fields are
called Distributors and Group Number. There are many Distributors and many
Group Numbers. The Distributors have many listings with the same group.
There are some Distributors that have no Group Numbers. I want to create a
list that has the Distributors listed once that have 1 or more Group numbers
associated with them.

Thank you for your help.
 
O

OfficeDev18 via AccessMonster.com

SELECT Distributors FROM YourTableName WHERE [Group Numbers] Is Not Null
GROUP BY Distributors;
 
G

Guest

Sheila,

Thanks for the input but your SQL provides multiple copies of the
Distributor when I only what to see the output to show the unique ones, no
matter how many there are. Those that appear in the list must be made up of
those Distributors that have group numbers associated with them. I don't
want the list to include Distributors that are in the table but do not have a
group number.

Does that help you understand what I am shooting for?

Any other suggestions?
Thanks
 
G

Guest

Hi there

Try something like this:
SELECT Table2.DIstributor, Table2.Group_Number, Count(Table2.Group_Number)
AS CountOfGroup_Number
FROM Table2
GROUP BY Table2.DIstributor, Table2.Group_Number
HAVING (((Count(Table2.Group_Number))>0));

You'll need to replace table and field names as appropriate

HTH

Sheila
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top