急求一SQL查询条件~~只有这30分了~~~~
已知SQL语句:
SELECT Begdate,Enddate, sum(Unckqty) as Unckqty from (
SELECT * FROM ( SELECT TRUNC(((sysdate-(CASE WHEN (Upd_date= ' ' or Upd_date is null) THEN Pur_date ELSE Upd_date END) )*24)) Begdate ,
TRUNC( ((sysdate-(CASE WHEN (Upd_date= ' ' or Upd_date is null) THEN Pur_date ELSE Upd_date END) )*24)+3 ) Enddate,
COUNT (Vendor) Unckqty FROM TABLE1 WHERE (Cfm_status=0)
GROUP BY ((sysdate-(CASE WHEN (Upd_date= ' ' or Upd_date is null) THEN Pur_date ELSE Upd_date END) )*24),
((sysdate-(CASE WHEN (Upd_date= ' ' or Upd_date is null) THEN Pur_date ELSE Upd_date END) )*24)+3)
WHERE Begdate> =24
)group by Begdate,Enddate ORDER BY Begdate
得到查询结果:
BEGDATE ENDDATE UNCKQTY
24 27 12
25 28 1
26 29 2
27 30 5
... ... ...
现在要得到如下结果:
BEGDATE ENDDATE