I am trying to display just the first row, in MYSQL the example was:
ORDER BY foo DESC LIMIT 1;
I believe oracle does not use the LIMIT
clause. I have tried the ROWNUM = 1
, but it does not seem to work. Is this the proper way of displaying the first line?
select customer_name,
MAX(balance) as "Highest Depositor Value"
from depositor
inner join account
on depositor.account_number = account.account_number
group by customer_name, balance
order by balance
where rownum = 1;
ERROR at line 4:
ORA-00933: SQL command not properly ended
I got the answer! Thanks
select customer_name,max(balance) as "Highest Depositor Value"
from depositor
inner join account
on depositor.account_number = account.account_number
group by customer_name, balance order by balance desc
fetch first 1 rows only;
CUSTOMER_NAME Highest Depositor Value
--------------- -----------------------
Lindsay 100000