making a table with a query

G

Gunther Kint

Hi,

I've got a problem to make a query. Here is a sketch of the situation.
There are two tables: in the first one there are people with a number.
In the second one there are activities that can be done planned on 3 times,
with the number of the people who are comming to the activeties.

first table:
NameID Name
1 Mike
2 Jason
3 Stan

second table:

NameID Hour(pm) Activeties
1 5pm baseball
1 6pm computers
1 7pm math

2 5pm computers
2 6pm math
2 7pm baseball

3 5pm baseball
3 6pm math
3 7pm computers


My question is now how I make a query to become the following:

name: 5pm 6pm 7pm
Stan baseball math Computer
Mike baseball computers math


I'm waiting hopefully that somebody can help me with this problem.
 
K

KARL DEWEY

Try this --
TRANSFORM First([second table].[Activeties]) AS FirstOfActiveties
SELECT [first table].Name
FROM [first table] INNER JOIN [second table] ON [first table].NameID =
[second table].NameID
GROUP BY [first table].Name
PIVOT [second table].[Hour(pm)];
 

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