Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Find the SUM of a Column (Join)
Old 05-15-2008, 11:59 AM Find the SUM of a Column (Join)
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
Hey..

I'm trying to find the sum the the 'Price' column. Can anyone give me an idea on how to do this with the following join


Code:
SELECT tblServiceLocation.Description, tblService.Description, tblVehicleService.Price,
tblVehicleService.ID, tblService.ID
FROM 
tblVehicleService, tblServiceLocation, tblService
WHERE tblVehicleService.ServiceLocationID = tblServiceLocation.ID
AND tblVehicleService.ServiceID = tblService.ID
SpudNik is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-15-2008, 12:00 PM Re: Find the SUM of a Column (Join)
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
Thanks in Advance for the help!!

-Nick
SpudNik is offline
Reply With Quote
View Public Profile
 
Old 05-15-2008, 01:43 PM Re: Find the SUM of a Column (Join)
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
You're using Access?

At the bottom of your query, add

GROUP BY
tblServiceLocation.Description, tblService.Description

Then get rid of the tbl wart from your table names.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 05-16-2008, 05:50 AM Re: Find the SUM of a Column (Join)
vividearth's Avatar
Experienced Talker

Posts: 33
Location: London, UK
Trades: 0
You forgot the SUM aggregate:

SELECT tblServiceLocation.Description, tblService.Description, SUM(tblVehicleService.Price),
tblVehicleService.ID, tblService.ID
FROM
tblVehicleService, tblServiceLocation, tblService
WHERE tblVehicleService.ServiceLocationID = tblServiceLocation.ID
AND tblVehicleService.ServiceID = tblService.ID
GROUP BY tblServiceLocation.Description, tblService.Description, tblVehicleService.ID, tblService.ID
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
vividearth is offline
Reply With Quote
View Public Profile Visit vividearth's homepage!
 
Old 05-19-2008, 12:13 PM Re: Find the SUM of a Column (Join)
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
Thank you both for the replies. Lemme give this a shot.

I like "tbl" naming convention
SpudNik is offline
Reply With Quote
View Public Profile
 
Old 05-19-2008, 12:24 PM Re: Find the SUM of a Column (Join)
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
So these all give the same result set; basically. The SUM column gets the sum for each particular price. What I need is the total of all the sums in the price column. Does that make sense?
SpudNik is offline
Reply With Quote
View Public Profile
 
Old 05-19-2008, 01:13 PM Re: Find the SUM of a Column (Join)
Skilled Talker

Posts: 60
Name: Nick Martin
Trades: 0
Thanks guys. I was able to get it done with a UNION.
SpudNik is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Find the SUM of a Column (Join)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32116 seconds with 12 queries