select to_char(CREDATE,'mm') CREDATE,to_char(CREDATE,'yyyy-mm') yearn,to_char(CREDATE,'yyyy') yearns,nvl(sum(inqty),0)inqty,nvl(sum(OUTQTY),0) OUTQTY from BMS_ST_IO_UNION_V group by to_char(CREDATE,'mm'),to_char(CREDATE,'yyyy'),to_char(CREDATE,'yyyy-mm') order by CREDATE,inqty,OUTQTY,yearn |