Perform subtraction using aggregate functions

0

I have a real estate table with the code , price and area fields. I need to figure out what the price difference is between the largest and smallest of the table (in a matter of area).

I tried this, but the difference between the highest and lowest price of the table, regardless of area, is made.

select (max(vl_preco)) - (min(vl_preco)) from imovel;

With the following query I have the return of the prices in the order of the area, but I would have to subtract the last value with the first one presented.

select max(vl_preco) from imovel group by nr_areatotal;

Is there any way to do this or any more efficient way?

Thank you in advance.

    
asked by anonymous 02.09.2015 / 21:28

0 answers