December 5, 2003 at 7:30 am
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
December 5, 2003 at 10:13 am
You need to correlate the existence subquery, e.g.
...
AND EXISTS (SELECT *
FROM A04Code
WHERE AcctNbr = a.AcctNbr
AND CodeValue LIKE '%KCBI%')
...
--Jonathan
--Jonathan
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply