Cummulating a field values based on criteria

rdev

Registered User.
Local time
Today, 21:34
Joined
Mar 2, 2009
Messages
18
I have a query with the following fields extracted from two tables:-

ID
Activity_type( can be Garbage removal, Tug, Towing, Ship_Chandling)
App_num ( approval number for each job done)
Ship_Name (name of ship)
Cost_of_charge_put (charge for each activity_type)

The Ship_Name and App_num( there is one app_num associated with a Ship_Name) will repeat as two or more of the same activity can be performed for a Ship_Name/App_num) In brief I want to find out all Garbage removal cost for a particular Ship_Name) . How should I design my query to achieve this
 
Something along these lines should work:

SELECT Ship_Name, Sum(Cost_of_charge_put) AS TotalAmt
FROM TableName
WHERE Activity_type = "Garbage removal"
GROUP BY Ship_Name
 
Thanks Paul
But how to set it in the access where do i copy these
Am absolutely a virgin acccess user
 
Start a new query, switch to SQL view, and paste that in.
 
Hi Paul
Tell me where i am wrong , I have twigged the code for it to run from the query qractivity

SELECT qractivity.Ship_Name, Sum(qractivity.cost_of_charge_put) AS TotalAmt
FROM qractivity
WHERE (((qractivity.activity_type)="Garbage"))
GROUP BY qractivity.Ship_Name;


The above is giving me a blank return with Name of Ship and TotalAmt as columns
 
That looks fine; is "Garbage" the actual value returned? You don't have lookup fields in your table, where perhaps we actually want an ID value there?
 

Users who are viewing this thread

Back
Top Bottom