In Oracle there is an "exists" statement will limit the results when just writing a sql script. Can you use exists in the same way in SQL Server? Here is script I am executing but it is not limiting the results as anticipated.
SELECT a.acctnbr, b.mediacontract_id A04contract_id, b.adddate,
a.mediacode, a.mediacontract_id contr_ID, a.odate, ordnbr,
a.*
FROM O01OMST a RIGHT JOIN
A04CODE b ON a.acctnbr = b.acctnbr
WHERE a.mediacontract_id NOT IN ('26', '199')
AND odate > '2002-12-20'
and exists (select acctnbr from A04CODE where codevalue like '%KCBI%')
ORDER BY a.acctnbr, a.odate DESC