i want to know if is possible to do something like this in mysql:
select 5 as a, 1 as b, a + b as c;
the problem is because i have this:
CONVERT( SUM(ifnull(commission,0.00)) ,DECIMAL(6,2)) as 'commission',
CONVERT( SUM(ifnull(income,0.00)) ,DECIMAL(6,2)) as 'income',
CONVERT( (SUM(ifnull(income,0.00)) - SUM(ifnull(commission,0.00))) ,DECIMAL(6,2)) as 'profit'
and of course the 3rd line would be more optimus if it dont have to SUM all the values again.
You can’t do
but you can do
(This is a nested query, which acts as a fake table when used from the outer query).
Applying thys to your case, we’d have:
Hope this helps.