SQLSyntaxErrorException:ORA-00933:SQL命令在oracle中未正确结束

时间:2019-03-11 06:45:23

标签: oracle

有人可以帮助我进行此查询吗?

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) ;

2 个答案:

答案 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

有关

的订购信息,请参考网址

https://www.techonthenet.com/oracle/order_by.php

答案 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