Operations with calculated fields from a mysql view

1

Good afternoon,

I have a view where there are several fields where I have several calculations, and the result of these calculations would like to use in other fields of this same view.

An example:

    select (tab1.campo1+tab1.campo2)/tab1.campo1-1 as margem, 
margem * 100 as %margem from tab1;

Since the calculation of "% margin" is done with the result of the previous calculation.

I tried to use it this way but the error below occurs:

  

Error Code: 1054. Unknown column 'commission net' in 'field list'

    
asked by anonymous 05.10.2016 / 21:56

0 answers