【发布时间】:2012-05-16 00:45:36
【问题描述】:
我需要将 where 条件放在 sql 的 NOT EXISTS 子句中。
在下面需要检查下面sql查询中的重复记录 我需要输入 Date='2012-05-07' 和 SecurityId='52211' 但问题是使用了内部连接,我是新手,不知道如何放置这些 where 子句 请帮忙。
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'
)
【问题讨论】:
标签: sql sql-server