1
Good afternoon,
I have a view where there are several fields where I have several calculations, and the result of these calculations I 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 this way but error occurs below:
Error Code: 1054. Unknown column 'settlement commission' in 'field list'
How are you doing it ? Put your Query. But I could see that the column name liquidation commission does not exist. As a suggestion, avoid name fields with accents, spaces and the like.
– Diego Souza
Edit that title for God’s sake, it looks like you’re yelling at us.
– Jéf Bueno
Just don’t answer, boss
– Américo Neto
The error that appears is Error Code: 1054. Unknown column name that I use in 'field list'
– Américo Neto
select (tab1.campo1+tab1.campo2)/tab1.campo1-1 the margins, (tab1.campo1+tab1.campo2)/tab1.campo1-1 * 100 the %margin from tab1;
– Motta
Yes, the view I have today is being similar. The problem is that the calculation I used as an example is much simpler than using it in the original code. I would like to use the result of one column to calculate another.
– Américo Neto
%margem
is not a alias valid, try withpercentual_margem
.– bfavaretto
ok, select (tab1.campo1+tab1.campo2)/tab1.campo1-1 the margins, margin * 100 the margem_percentage from tab1; Likewise it does not work
– Américo Neto