473,418 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Query help!

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
3 1147
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
7
by: Simon Bailey | last post by:
How do you created a query in VB? I have a button on a form that signifies a certain computer in a computer suite. On clicking on this button i would like to create a query searching for all...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.