0

以下の注文表がありますが、今日の日時 (17:00 USA) までに注文ステータスが「処理済み」で、ステータスが「キャンセル済み」ではないレコードを取得したいです。問題を解決するのを手伝ってください。

order id  ordername order_status  cancel_status  order_time           cancel_time 
==============================================================================================    
1         Iphone    processed     cancelled      10/08/2012 16:00:00  10/08/2012 16:00:00        
2         samsung   notprocessed  null           null                 null        
3         nokia     processed     cancelled      10/08/2012 16:00:00  10/08/2012 17:00:00    
4         motorola  notprocessed  null           null         null    
5         HTC       processed     null           10/08/2012 17:00:00  null

以下の方法で試しましたが、レコードが返されませんでした。助けてください。

SELECT * 
FROM 
    order 
WHERE 
    to_char(order_time,'YYYYMMDD HH24:MI:SS')>To_char(sysdate,YYYYMMDD) || ' '|| '17:00:00' 
and to_char(cancel_time,'YYYYMMDD HH24:MI:SS')>To_char(sysdate,YYYYMMDD) || ' '|| '17:00:00' 
and order_time is null 
and cancel_time is null
4

2 に答える 2

0
Select * from order 
where 
( to_char(order_time,'YYYYMMDD HH24:MI:SS')>To_char(sysdate,YYYYMMDD) || ' '|| '17:00:00' 
or order_time is null ) 
and ( to_char(cancel_time,'YYYYMMDD HH24:MI:SS')>To_char(sysdate,YYYYMMDD) || ' '|| '17:00:00' 
or cancel_time is null )
于 2012-10-08T18:34:50.567 に答える
0
select * 
from order o 
where o.order_status != 'processed' 
  and o.cancel_status = 'cancelled' 
  and o.order_time < (trunc(sysdate) + 17/24) 
  and o.cancel_time < (trunc(sysdate) + 17/24)
于 2012-10-08T18:35:16.617 に答える