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.
x
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