I have a problem, since I have a table which has the fields of VAT, price, productname, date, what I want is to obtain the maximum, as of a date, and I do it, but now I need that After obtaining the maximum price, check if the VAT is 0 or 1, if it is 1 multiply it by 1.16 and if it is 0 you will not realize anything. This is the code I'm trying to use.
select MAX(CASE WHEN iva='1' then Precio*1.16 end)as Precio from Gastos
WHERE NombreConcepto = 'REFRESCO'and FechaGasto>='20170101'
This code gets me the maximum but it has VAT, and if there is another higher price that has no VAT, it excludes it, first I want to take the maximum to the Price column, then see if I have to multiply it by 1.16 and if not so leave it ... some solution.