If you create a function and name it is there any way to use that name later in your statement?
For example in the code below I named the sellprice-buyprice as PROFIT but I can’t seem to use that again as it errors as an invalid identifier. If I can’t do that, please let me know how I would display the max profit entry in that column.
SELECT item, buyprice, sellprice,
sellprice-buyprice as “PROFIT”
FROM auctions
WHERE PROFIT = (select MAX(PROFIT) from auctions);
Could you try this statement:
select * from (select item, buyprice, sellprice, sellprice-buyprice as “PROFIT”from auctions order by 4 desc) where rownum = 1;