I have a query that SUM all the amounts GROUP BY different categories. I would like to get as well the % of that SUM amount by the total.
My query is the next:
SELECT category.name, SUM(account.amount_default_currency) FROM account
INNER JOIN accounts ON account.accounts_id = accounts.id
INNER JOIN category ON account.category_id = category.id
INNER JOIN category_type ON category.category_type_id = category_type.id
GROUP BY category.name;
And I get:
| name | SUM | 
|---|---|
| salary | 230 | 
| restaurants | 2254 | 
How could I do it?
 
    