Hello,
Is there a way to combine the 2 select statements pasted below? I want to use the second select as a NOT IN select statement. I want to select the data from the first select and be sure to NOT select any data that matches the select parameters in the second query.
Thanks.
----------------First select statement ------------------------------------------------------
SELECT ac.CustKey, p.FirstName, p.MiddleName, p.LastName, p.Address1, p.Address2, p.City, p.State, p.Country, p.Zip, 'Club Drop' AS Expr1
FROM Person AS p WITH (nolock) INNER JOIN
BI_Membership AS m WITH (nolock) ON p.Per_ID = m.Per_ID INNER JOIN
AcctCustomer AS ac WITH (nolock) ON p.Per_ID = ac.Per_ID LEFT OUTER JOIN
CountryInformation AS ci WITH (nolock) ON p.Country = ci.FullCountryName
WHERE (m.BI_MembershipType_ID = '3') AND (m.Type = 'INACT') AND (CONVERT(varchar, m.DeActiveDate, 112) BETWEEN CONVERT(varchar, DATEADD(mm, - 1, GETDATE())
- DATEPART(dd, GETDATE()) + 8, 112) AND CONVERT(varchar, DATEADD(mm, 0, GETDATE()) - DATEPART(dd, GETDATE()) + 7, 112)) AND
(p.Per_ID NOT IN
(SELECT Per_ID
FROM BI_Membership
WHERE (Per_ID = p.Per_ID) AND (InActive = 0) AND (BI_MembershipType_ID
IN ('1', '3', '4', '7'))))
-------------------------------------------Second select statement ----------------------------
SELECT DISTINCT per.FirstName, per.LastName, per.Per_ID, per.EmailAddress, vol.KCode
FROM BI_Membership AS mem INNER JOIN
BI_Volunteers AS vol ON mem.Per_ID = vol.Per_ID AND vol.BI_Volunteers_ID =
(SELECT TOP 1 BI_Volunteers_ID
FROM BI_Volunteers
WHERE (Per_ID = mem.Per_ID) AND (InActive = '0')) INNER JOIN
Person AS per ON mem.Per_ID = per.Per_ID
WHERE (mem.BI_MembershipType_ID IN ('1', '3', '4')) AND (mem.InActive = '0')
ORDER BY per.LastName