1. varianta:
Kód:
select sm.Client.name, sm.Client.longname
from sm.Client JOIN gbd.InstructionRules
on sm.Client.ID = gbd.InstructionRules.ClientID
where gbd.InstructionRules.ruleid not in (select distinct RuleID from clr.AllocationsAudit where RevisionType = 19)
2. Varianta
Kód:
select c.name, c.longname
from sm.Client c JOIN gbd.InstructionRules ir
on c.ID = ir.ClientID
LEFT JOIN
(select distinct RuleID from clr.AllocationsAudit where RevisionType = 19) rl
ON
ir.ruleid = rl.ruleid
where rl.ruleid is NULL
Jinak obecně bych se snažil databázovým CROSS Joinům spíše vyhýbat a data z jedné DB natahoval v nějakém periodickém období do druhé DB.