Why this work does not work, I am trying to get the previous and current value to calculate the percentage change. I understand both values ββcorrectly, but now, how can I reuse them to perform a mathematical operation
When I try to execute the command below, I get ERROR 1054 (42S22): Unknown column "currentVal" in the "list of fields"
SELECT IFNULL(DValue,0) as currentVal,
(SELECT IFNULL(DValue,0)
FROM ...
WHERE...) as previousVal,
(currentVal-previousVal)/previousVal
FROM ...
WHERE ...;
source
share