bringing info in from 2 tables

D

Dan McClelland

It sounds like you are attempting to get a count of
unorphaned data. In other words, how many clients from my
clients table have matching data in my counseling session
table AND my trainee attendee table. Here's a quick and
dirty (yet effective) solution...

Create an aggregate query that gives you a count of
clients who were counselled for the given quarter (the
count function will eliminate the duplicates). Create a
separate query that does the same for clients trained.
Then create a third query, adding the first two queries
into the table/query pane, joined on the client field, and
include the counts or a calculation to sum the counts.
-----Original Message-----
I have 2 separate tables-Counseling session info and
trainee attendee. They are both linked to the client info
table (which has each clients demographic info). What I
need to do is find out the total # of clients (counseled
and trained) from a quarter. I am trying to develop a
query or a report that will combine this info but I am
having troubles designing it. I want clients,
unduplicated (many may be trained or counseled more than
once a quarter) pulled together so that I have the total
clients that we served for a quarter. When I try to do
it, I end up with only the clients that are listed as both
trained and counseled rather than all of them. Once I can
get a query or a report to list them together, then I need
to use the client information table to pull the
demographics on each client. I do have dates in the
client info table, but I can't use that for the total
clients because many clients may be counseled or trained
while they first became a client 2 years earlier and that
is the date on their intake (client information). If
anyone can help me I would really appreciate it.
The field that are the primary in the client information
and what I am trying to bring together are named
Client_Number.
 
G

Guest

I'm trying to set up queries to count...but when I set the Total section to count for the Client Number, it brings back a table with numbering 1-9 (some listed more than once), but there are a lot more than 9 different clients that were counseled. I'm confused as to how I'm supposed to have it count the number of clients, eliminating the duplicates.
 
J

John Vinson

Is there a way to have a query pull (in 1 listing) all clients from both counseled and training attendee tables but to sort out the duplicates?

Yes: a UNION query.

SELECT ClientID FROM Counseling WHERE <criteria>
UNION
SELECT ClientID FROM Training WHERE <criteria>

You need to do this in the SQL window (using your own table and
fieldnames of course), the grid doesn't handle UNIONs (psst: the grid
is a stooge for management! <g>)

See the online help for UNION, it's pretty good.
 

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

Similar Threads


Top