SUM of grouped COUNT in SQL Query
sql
Solution
SELECT name, COUNT(name) AS count
FROM table
GROUP BY name
UNION ALL
SELECT 'SUM' name, COUNT(name)
FROM table
OUTPUT:
name count
-------------------------------------------------- -----------
alpha 1
beta 3
Charlie 2
SUM 6
Problem
I have a table with 2 fields: ``` ID Name -- ------- 1 Alpha 2 Beta 3 Beta 4 Beta 5 Charlie 6 Charlie ``` I want to group them by name, with 'count', and a row 'SUM' ``` Name Count ------- ----- Alpha 1 Beta 3 Charlie 2 SUM 6 ``` How would I write a query to add SUM row below the table?