Skip to content
Advertisement

SQL query to get the Sum of all column values in the last row in access table

I have a table like below. I want to sum parts column and write the total after the last record. how to specify total and the result in SQL query.

Model     parts

Model1    4 
Model2    2
Model3    6
Model4    5
Model5    7
Total     24

Advertisement

Answer

Try this query

SELECT  models, parts
FROM    your_table
UNION
SELECT  'Total' AS models, SUM(parts) AS parts from your_table
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement