我想只获得一行日期:
select Datum, ZONE_2, 0 as SEEFRACHT
from (
select to_char(arch_p.ANKUEND_TERMIN,'dd.mm.yy') as Datum, Count (*) as ZONE_2
from ARCH_PACKSTUECK arch_p
where (arch_p.lbr_auf_nr like '%02')
group by to_char(arch_p.ANKUEND_TERMIN,'dd.mm.yy')
union all
select to_char(ANKUEND_TERMIN,'dd.mm.yy') as Datum, Count (*) as ZONE_2
from PACKSTUECK p
where(p.lbr_auf_nr like '%02')
group by to_char(p.ANKUEND_TERMIN,'dd.mm.yy')
order by Datum
)
DATUM |ZONE_2|SEEFRACHT 01.02.17 5 0 01.02.17 588 0 02.02.17 52 0 02.02.17 484 0
答案 0 :(得分:1)
试试这个
select Datum, sum(ZONE_2) as ZONE_2, 0 as SEEFRACHT
from (
select to_char(arch_p.ANKUEND_TERMIN,'dd.mm.yy') as Datum, Count (*) as ZONE_2
from ARCH_PACKSTUECK arch_p
where (arch_p.lbr_auf_nr like '%02')
group by to_char(arch_p.ANKUEND_TERMIN,'dd.mm.yy')
union all
select to_char(ANKUEND_TERMIN,'dd.mm.yy') as Datum, Count (*) as ZONE_2
from PACKSTUECK p
where(p.lbr_auf_nr like '%02')
group by to_char(p.ANKUEND_TERMIN,'dd.mm.yy')
) as t
group by Datum
order by Datum