0
I want to know the average of the values (value m2) in a table using AVG() (or otherwise).
I have a table in MYSQL with the columns id, total value (Total value), value m2 (Value per m²) and area.
In some lines the value m2 is empty and in others the total value is empty.
Is there any way to make a select for if the field is empty, it makes an account? Type the below:
tabela_terrenos
id|valortotal|valorm2|area
1 |100000 | 1000 |100
2 |150000 | |100
3 | | 1500 |200
then I’d need it before I brought the average, something like:
SE valorm2 = vazio, então valorm2 = valortotal / area
SENÃO valorm2 = valorm2
SELECT AVG(valorm2)
FROM tabela_terrenos
the answer below solved the problem?!
– rLinhares