I have the following query that has a sub query giving me the Categories
column. When I try to add the WHERE
clause, I get an Invalid column name 'Categories'
error.
SELECT
l.LID,
Company,
Doors,
City,
Region,
Country,
Categories = STUFF((
SELECT
CONVERT(varchar(100), Junc_CatID) + ', '
FROM BND_ListingJunction_testing j
WHERE j.Junc_LID = l.LID
FOR XML PATH('')), 1, 2, '')
FROM BND_Listing_testing l
--FILTERS
WHERE
(Categories = '[querystring:filter-Category]' or '[querystring:filter-Category]'='All')
GROUP BY
LID,
Company,
Doors,
City,
Region,
Country