I have a database, with a column where I have priorities from 1 to 5 and I have column "Category". I want to calculate percentage of each priority group of sum in each category.
Here you can see my database, where I want to get % of priority for each group
For this example I should get:
Priority 1 - Count 1 - % 50
Priority 5 - Count 1 - % 50
What I tried and didn't work:
I have trouble with query so any help would be appriciated
select priority, count(*) as priority_count, 100 * count(*) / (select count(*) from tasks where category = 'medications') as percent from tasks where category = 'Medications' group by priority