Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi guys,
I have an Access database that consists (in brief) of the following tables:Visit
*******
VisitID (PK)
VisitDateActivity_Visit
*******
VisitID (PK)
ActivityID (PK)Activity
*******
ActivityID (PK)
ActivityName
Cost
I'd like to make a query that groups activites together so I can see the total cost of each activity per day. So it looks something like:Date---Activity----Cost
************************
01/01--Blah Blah--$20.00
01/01--Some text--$25.00
01/01--More text--$15.50I figure I'll have to use at least two inner joins and also 'group by' somewhere along the line. I've tried something like this:
SELECT Visit.VisitDate, Activity.ActivityName, sum(activity.Cost) AS [Total Cost]
FROM VISIT
INNER JOIN Activity_Visit ON Visit.VisitID = Activity_Visit.VisitID
INNER JOIN Activities ON Activity_Visit.ActivityID = Activities.ActivityIDbut i haven't got it quite figured out yet. Any help is appreciated!

First view the query in design view.
Link
VisitTable-VisitID with Activity_VisitTable-Visit IDand
Activity_VisitTable-ActivityID with ActivityTable-ActivityIDJust click on one field and drag to connect to the second field.
then select fields Date, Activity Date and Cost.
clck on the Sum (Σ) button and for field Cost select SUM. the other 2 fields leave it as GROUP BY.
The graphical interface can simplify a lot the creation of codes.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |