Computing.Net > Forums > Database > Inner joins in MS Access

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Inner joins in MS Access

Reply to Message Icon

Name: randomadam31
Date: April 16, 2007 at 04:14:36 Pacific
OS: Windows XP SP2
CPU/Ram: P4/1GB
Comment:

Hi guys,
I have an Access database that consists (in brief) of the following tables:

Visit
*******
VisitID (PK)
VisitDate

Activity_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.50

I 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.ActivityID

but i haven't got it quite figured out yet. Any help is appreciated!



Sponsored Link
Ads by Google

Response Number 1
Name: rousou
Date: April 20, 2007 at 02:20:47 Pacific
Reply:

First view the query in design view.

Link
VisitTable-VisitID with Activity_VisitTable-Visit ID

and
Activity_VisitTable-ActivityID with ActivityTable-ActivityID

Just 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.


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Inner joins in MS Access

How to merg fields in MS Access www.computing.net/answers/dbase/how-to-merg-fields-in-ms-access/461.html

calculation in ms access www.computing.net/answers/dbase/calculation-in-ms-access/657.html

How to create a function in MS Acce www.computing.net/answers/dbase/how-to-create-a-function-in-ms-acce/328.html