如果明细表中只有客户在银行中最新余额的情况,可以使用下面的SQL: SELECT RANK () OVER (PARTITION BY org_name ORDER BY current_bal DESC), cust_id, org_name, current_bal FROM ( SELECT cust_id, org_name, SUM (current_bal) current_bal FROM t03_acct_trade_detail GROUP BY cust_id, org_name)