By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Query help!

P: n/a
Is there a way to sum a specific column in a query? What I have is a
query that pulls several line based on a id field. I want to total just
1 column in the query and have it report back as new column. Example

Id Site price date
101 201 40.00 1-11-05
101 404 25.00 1-11-05
101 600 15.00 1-11-05

and I would like to create a new column for total price that would show
Id Site price date totalprice
101 201 40.00 1-11-05 80.00
101 404 25.00 1-11-05 80.00
101 600 15.00 1-11-05 80.00

Can someone explain how to do that? Thanks for help!

Dec 14 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try something like this

SELECT
YourTable.ID
, YourTable.Site
, YourTable.Price
, YourTable.Date
, MyQuery.Total
FROM YourTable
INNER JOIN
(SELECT YourTableID, Sum(YourTable.Price) As Total
FROM YourTable GROUP BY YourTable.ID) AS MyQuery
ON YourTable.ID = MyQuery.ID
ORDER BY YourTable.ID

--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast
"deercreek" <da*@deercreekcg.com> wrote ...
Is there a way to sum a specific column in a query? What I have is a
query that pulls several line based on a id field. I want to total just
1 column in the query and have it report back as new column. Example

Id Site price date
101 201 40.00 1-11-05
101 404 25.00 1-11-05
101 600 15.00 1-11-05

and I would like to create a new column for total price that would show
Id Site price date totalprice
101 201 40.00 1-11-05 80.00
101 404 25.00 1-11-05 80.00
101 600 15.00 1-11-05 80.00

Can someone explain how to do that? Thanks for help!

Dec 14 '05 #2

P: n/a
I need to be able to do it in the regular query enviroment not with
sql, because I have about 20 tables feed ing this thing. Any ides in
the query.

Dec 14 '05 #3

P: n/a
"deercreek" <da*@deercreekcg.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I need to be able to do it in the regular query enviroment not with
sql, because I have about 20 tables feed ing this thing. Any ides in
the query.


If, by "the regular query environment", you mean the query builder, you can
still use the method that Danny showed you. Just build the subquery with
the sum separately and save it. Then add it to your other query.

--
Randy Harris
I'm pretty sure I know everything that I can remember.

Dec 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.