asked on
tags must have a closing
tag.ASKER
select count(*)
FROM AROpenTransactions t
LEFT OUTER JOIN Clients c ON t.Accountnumber = c.Accountnumber
where c.Accountnumber IS NULL
-- if this number is zero then an INNER JOIN is fine
select count(*)
FROM AROpenTransactions t
LEFT OUTER JOIN Clients c ON t.Accountnumber = c.Accountnumber
LEFT OUTER JOIN clientcontacts cc ON t.Accountnumber = cc.Accountnumber
AND cc.NotifyOnInvoices = 1 -- ( move the former WHERE condition here as join condition)
where cc.Accountnumber IS NULL
-- if this number is zero then an INNER JOIN is fine
if either number is > zero then use an outer join
Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.
TRUSTED BY
ASKER
your code will return only one value.
I'm trying to get all values.
some Accountnumber will have more than one ClientContacts .
thanks again,