I try to find
select Code, count(Code)
from Table
group by code
and need result to look like this:
CodePudding user response:
You can do it as follows:
SELECT Code, count(Code) as count
FROM Table
GROUP BY count
You just need to adjust your GROUP BY condition.
CodePudding user response:
You probably need to do this somewhere other than in SQL, but it still works to have the total column. If you want to work on the ordering to make sure that the TOTAL column is at the bottom. Add an ortdering column and order by that
select Code, count(Code)
from Table
group by code
UNION
select 'All' as Code, count(Code) as COUNT
from Table