【发布时间】:2015-12-26 02:05:51
【问题描述】:
我试图只显示第一行,在 MYSQL 中的示例是:
ORDER BY foo DESC LIMIT 1;
我相信 oracle 不使用LIMIT 子句。我试过ROWNUM = 1,但它似乎不起作用。这是显示第一行的正确方式吗?
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
我得到了答案!谢谢
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
【问题讨论】: