в догонку пример: главный датасет
select PL.ItemId, PL.InventDimId from PurchLine as PL
join InventDim as IDim on IDim.InventDimId = PL.InventDimId
and (IDim.inventlocationid = @inventlocationid) or (@inventlocationid = '***'))
------
дочерний
select IL.inventlocationid, IL.name
from inventlocation as IL
where IL.shopGroupId = 'Маг. Опта'
union
select '***', 'Все магазины'
|