/build/static/layout/Breadcrumb_cap_w.png

Total a value in Reports

I know there will be someone clever who has done this. I have a report that lists Labour Cost, Part Cost and Total cost. These are calculated using a series of custom rules. When I run the report for the month there are more than 100 records but I would like to put a total for each of those columns at the bottom of the report. 



0 Comments   [ + ] Show comments

Answers (1)

Posted by: JasonEgg 3 years ago
Red Belt
1

so let's say your original query looks like this:

SELECT 

    Item, Labour_Cost, Part_Cost, Total_cost

FROM

    TABLE1

WHERE

    Item LIKE 'ABC%'

in order to add a totaling row we have to build a new (one-entry) table and then "UNION" the two tables together. So you would add the following at the bottom of the query:

UNION

SELECT 

    'Total' AS Item,

    SUM(Labour_Cost) AS Labour_Cost,

    SUM(Part_Cost) AS Part_Cost,

    SUM(Total_Cost) AS Total_Cost

FROM

    TABLE1

WHERE

    Item LIKE 'ABC%'

GROUP BY ''


Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ