2017-02-09 8 views
-2

私は日付が1行のみを取得したいと思います:/:GROUP BYまたは追加することは

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 

enter image description here

+1

を参照してください。HTTP試してみてください/meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems- to-me-to-be-a-very-simple-sql-query – Strawberry

答えて

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   
+0

素晴らしい、ありがとう:-) – Emjot