I have a MySQL query that performs a brief operation (summing up the counts in a select expression), and I want to use the result to perform a mathematical operation, but I get an error.
Table:
id | group | count |
-----------------------------
1 1 3
2 1 2
Query:
select id, count,
(select sum(count) from table group by group) as total,
count/total as percent
from table
The error is that the table does not have a real βcommonβ column. How can I make the request work?
source
share