Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / December 2005

Tip: Looking for answers? Try searching our database.

Query help!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deercreek - 14 Dec 2005 16:52 GMT
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!
Jay - 14 Dec 2005 18:35 GMT
Hope this works for you:

SELECT tablename.Id, tablename.Site, tablename.price, tablename.date,
t2.totalprice
FROM  (SELECT Id, Sum(price) as totalprice
            FROM tablename
            GROUP BY id) t2
RIGHT JOIN tablename ON t2.Id = tablename.Id;

If there's an error in the FROM clause, you may need to create two separate
queries.

Jay

> 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
[quoted text clipped - 13 lines]
>
> Can someone explain how to do that? Thanks for help!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.