I'm running the below on MS Server Management studio v11.02
However' I'm getting an error saying that the:
The multi-part identifier "PO.LastPo" could not be bound.
SELECT DISTINCT PO.LastPo
INTO #IncludedPoll
FROM
(
-- Inner query makes sure member was actually enrolled for 2 yrs
SELECT LastPo, COUNT(*) AS Periods
FROM [Cye].[2_output_lastPoll] PO
WHERE PO.PollPq IN (1,2)
GROUP BY LastPo
) A
WHERE Periods IN (1,2) AND A.LastPo NOT IN (SELECT LastPo FROM #FilterPoll)
#FilterPoll
#IncludedPoll
You named your inner query A
, so it should be SELECT DISTINCT A.LastPo
instead of PO.LastPo