如何修改这条SQL语句才能实现所要求的效果~~急~~~~
select Begdate ,Enddate, sum(Unckqty) as Unckqty 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 1
25 28 1
26 29 3
27 30 34
28 31 12
... .... .....
要求得到:
Begdate Enddate Unckqty
24 27 a
28 31 b
32 35 ...
... ....