- Code: Alles auswählen
select trunc(HIS.HIS_START)
as "Datum"
,'' as "DB_RR_Basis"
, sum(case when HIS.CAM_ID in (799) and HIS.RES_ID in (1006) then 1 else 0 end)
as "Kunde mit Bestellung"
,'' as "Sofortbestellung Ja"
from ts$_customer CUST
,ts$_supplement_344 CUST_SUP
,ts$_history HIS
where 1=1
and CUST.MAN_ID = 344
and HIS.PROJ_ID = 468
and CUST.man_id=CUST_SUP.man_id(+)
and CUST.cust_id=CUST_SUP.cust_id(+)
and CUST.man_id=HIS.man_id(+)
and CUST.cust_id=HIS.cust_id(+)
group by trunc (HIS.HIS_START)
UNION
select trunc(HIS.HIS_START) as "Datum"
,'' as "DB_RR_Basis"
,'' as "Kunde mit Bestellung"
, sum(case when HIS.CAM_ID in (799) and HIS.RES_ID in (1006) then 1 else 0 end)
as "Sofortbestellung Ja"
from ts$_customer CUST
,ts$_supplement_344 CUST_SUP
,ts$_history HIS
where 1=1
and CUST.MAN_ID = 344
and HIS.PROJ_ID = 468
and CUST_SUP.STRNEINKS = 'Ja - Umstellung auf Komfort'
and CUST.man_id=CUST_SUP.man_id(+)
and CUST.cust_id=CUST_SUP.cust_id(+)
and CUST.man_id=HIS.man_id(+)
and CUST.cust_id=HIS.cust_id(+)
group by trunc (HIS.HIS_START)
Viele Grüße Stefan