select distinct d.saletype, d.saleid, d.saledate from supermag.FVMapRep d where d.saletype in ('CS', 'CR') and d.saledate between TO_DATE('20071201','YYYYMMDD') and TO_DATE('20080229','YYYYMMDD') and (exists (select 1 from supermag.SMDocProps p where p.doctype=d.saletype and p.docid=d.saleid and p.paramname='Cash.Stat.CalcTaxes' and p.paramvalue='*') or not exists (select 1 from supermag.SMDocProps p where p.doctype=d.saletype and p.docid=d.saleid and p.paramname='Cash.Stat.CalcTaxes') )