我有以下 sql 查询表现不佳:
SELECT
Count(ExtCardID) as CardCount
from
CardIDs CARDS with (NoLock)
inner join
(select CustomerPK
from GroupMembership with (NoLock)
where CustomerGroupID = 14 and Deleted = 0) as GM on GM.CustomerPK = CARDS.CustomerPK
上述连接中的以下Select
部分返回了 800 万条记录:
select
CustomerPK from GroupMembership with (NoLock)
where
CustomerGroupID = 14 and Deleted = 0
有没有更好的方法来编写上面的sql代码?请指教。