Create Table DBONE AS (
Select distinct count(X) as Count, Y, Z
FROM Schema.Table
Where (Schema.Table.X like '%Retire%' or Schema.Table.X like '%Obsolete%')
Group by (X, Y, Z)
)
ORDER BY X, Y, Z asc;
How can I abbend a sum to the end of the count(X) statement as either another column which calculates the sum of the count, or on the bottom of the row?
I’ve tried
Union All
Select 'SUM' X (table)
From Table
but this is incorrect
Your query doesn’t make real sense. The count is always going to return “1”, because you are grouping by X. Also, you don’t need the distinct when using group by.
You may want: