2016-10-08 60 views
0

問題:從帳戶中查找具有最高餘額的客戶名稱和帳戶號碼。查詢中特定部件的關係重命名(oracle10g)

My_query:

select customer_name 
from (
    select * 
    from depositor, 
     account 
    where depositor.account_number = account.account_number **as T** 
    and balance >= (select balance from T) 
); 

我可以給一個名稱 'T' 的部分(select....depositor.account_number = account.account_number)

+0

它給了我一個錯誤! – arifCoder

回答

1

據我所知,你有兩個問題 1)如何獲得與hiest blance的CUSTOMER_NAME

一)與訂貨

select customer_name 
from ( select * 
from depositor,account 
where depositor.account_number = account.account_number 
order by balance DESC) 
where rownum < 2 ; 

B)

​​

2)我們如何可能會在查詢塊中使用別名。你可以使用建設「與」

with t as (select * from depositor,account where depositor.account_number = account.account_number) 
select customer_name from T 
where balance >= (select max(balance) from T) ;