有人可以帮助我进行此查询吗?
select trans_dt,trans_acc_no,trans_desc,trans_amt,transaction_type as trans_type , replace(trans_type,'credit','CR'), replace(trans_type,'debit','DB') from bank_transaction
where (trans_amt>10000 and cust_type != bank_rd_account)
order by(trans_type asc and trans_date desc) ;
答案 0 :(得分:2)
删除和在order by子句之间-它给你语法错误
select
trans_dt,
trans_acc_no,
trans_desc,
trans_amt,
transaction_type as trans_type,
replace(trans_type, 'credit', 'CR'),
replace(trans_type, 'debit', 'DB')
from
bank_transaction
where
(
trans_amt > 10000
and cust_type != bank_rd_account
)
order by
trans_type asc,
trans_date desc
有关
的订购信息,请参考网址答案 1 :(得分:0)
在sql order
中,不能在方括号内给出。应按以下方式给出
示例:
SELECT * FROM table_name ORDER BY column1 ASC|DESC, column2 ASC|DESC
所需查询如下:
select
trans_dt,
trans_acc_no,
trans_desc,
trans_amt,
transaction_type as trans_type,
replace(trans_type, 'credit', 'CR'),
replace(trans_type, 'debit', 'DB')
from
bank_transaction
where
trans_amt > 10000
and cust_type != bank_rd_account
order by
trans_type asc,
trans_date desc