I am trying to create a report where I am grouping sales data by a sales rep for a special promotion items. Under the sales rep, I want to show the complete list of promo items, even though the rep may not had had any sales. Here is sample of the query that returns the sales but when I group by rep in the report I can only get a list of items sold:
SELECT
drdl01 category
, imlitm as item
, imdsc1 as desc1
, imsrp6 as promo
, promoname='Sticker Catalog Promotions (CAT03-3)'
, sum(sdaexp)/100 sales
, sdslm2 rep
from proddta.f4211
right join proddta.f4101
on sdlitm=imlitm and imsrp6='CAT033'
inner join prodctl.f0005
on drsy=41 and drrt='S2' and ltrim(drky)=imsrp2
where
sdtrdj>=103085 and sdtrdj<=103090 -- booking period
and not sdlnty in ('F','M','RS')
and sddct='RI'
and sdsocn=0
and sdktln=0
group by
drdl01
, imlitm
, imdsc1
, imsrp6
, sdslm2
SELECT
drdl01 category
, imlitm as item
, imdsc1 as desc1
, imsrp6 as promo
, promoname='Sticker Catalog Promotions (CAT03-3)'
, sum(sdaexp)/100 sales
, sdslm2 rep
from proddta.f4211
right join proddta.f4101
on sdlitm=imlitm and imsrp6='CAT033'
inner join prodctl.f0005
on drsy=41 and drrt='S2' and ltrim(drky)=imsrp2
where
sdtrdj>=103085 and sdtrdj<=103090 -- booking period
and not sdlnty in ('F','M','RS')
and sddct='RI'
and sdsocn=0
and sdktln=0
group by
drdl01
, imlitm
, imdsc1
, imsrp6
, sdslm2