I need to put where condition inside NOT EXISTS clause in sql.
In below need to check the duplicate records for that in below sql query
i need to put Date=’2012-05-07′ and SecurityId= ‘52211’
but problem is inner join is used and i’m new bie not getting how to put these where clause
please help.
SELECT DISTINCT
SecurityPriceId
FROM
dbo.Indicative Bond
INNER JOIN
dbo.BondPrice BondPrice ON
Indicative.SecurityId = BondPrice.SecurityId AND
BondPrice.SecurityPriceSourceId = @SecurityPriceSourceComposite
WHERE
Date = @Date -- Date='2012-05-07' like this
AND
NOT EXISTS
(
SELECT
'z'
FROM
dbo.Reporting_BondPrices
WHERE
Reporting_BondPrices.SecurityId = BondPrice.SecurityId AND
Reporting_BondPrices.Date = BondPrice.Date
--how can i put Date='2012-05-07' and SecurityId='52211'
)
Following your update, I think (??) you want this?
Earlier attempt at decoding your question:
You can alias your tables, like this: