assigning mysql value to variable inline -


why doesn't work i'm trying previous , current value calculate percent change. both values correctly how can reuse them math operatio

when try below command error 1054 (42s22): unknown column 'currentval' in 'field list'

            select ifnull(dvalue,0) currentval,                        (select ifnull(dvalue,0)                         ...                        where...) previousval,                        (currentval-previousval)/previousval             ...             ...; 

wrap query around have , calculate percentage there:

select currentval, previousval,         (currentval-previousval)/previousval percentchange     (select ifnull(dvalue,0) currentval,                    (select ifnull(dvalue,0)                         ...                        where...) previousval               ...               ...) t 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -