I have this query with an sub query as clicks
I want to do then where clicks > 0, but I get an error that this is not an recognized column.
SELECT top 10 *, (select count(*) FROM po_events aeclk WITH(NOLOCK) where (aeclk.[source] = ae.[source]) as clicks
FROM archived_events ae with(NOLOCK)
where clicks > 0
While I agree with the comment that this is a possible duplicate, I’d also like to point out that correlated subqueries can be inefficient; killing two birds with one stone, you could do something like: