想问下这段sql有能调优的地方吗?必须关联两个表一起查!
select * from (select *
from (select TRANS_ID,
txn_id,
(select name
from t_type a
where a.code = t.txn_id
and category = 'TXN') txn_name,
(case
when (TRAN_STATUS = 1) then
'有效'
when (TRAN_STATUS = 2) then
'撤销'
when (TRAN_STATUS = 3) then
'被冲正'
else
'暂挂'
end) TRAN_STATUS,
'卡' status,
txn_date,
pan,
txn_amt,
shop_id,
(select name from t_shop a where a.code = t.shop_id) shop_name,
cust_no,
(select name
from t_client_info a
where a.code = t.cust_no) cust_name,
g_id,
(select name from t_goods s where s.code = t.g_id) g_name,
g_price,
g_qty,
old_pan
from t_transaction_int t
order by txn_date desc)
where rownum <= 10000
union
select *
from (select TRANS_ID,
txn_id,
(select name
from t_type a
where a.code = t.txn_id
and category = 'TXN') txn_name,
'有效' TRAN_STATUS,
'卡' status,
txn_date,
pan,
txn_amt,
shop_id,
(select name from t_shop a where a.code = t.shop_id) shop_name,
'' cust_no,
(case
when (t.issu_bank is null) then
'卡'
else
(select name from t_bank a where a.code = t.issu_bank)
end) cust_name,
g_id,
(select name from t_goods s where s.code = t.g_id) g_name,
g_price,
g_qty,
'' old_pan
from t_transaction_ext t
order by txn_date desc)
where rownum <= 10000)
order by txn_date desc