I was wondering how I can retrieve multiple result sets based on one CTE? Something like what I have below - but obviously this doesn't work.
Does anyone know how I can get these 2 (or more) sets of data, based on that one CTE? (more, as in that it would be nice to get the total record count from this same CTE as well.)
;WITH CTE AS
(
SELECT
Column1, Column2, Column3
FROM
Product
WHERE
Name LIKE '%Hat%' AND Description Like '%MyBrand%'
)
SELECT DISTINCT CategoryId FROM CTE
SELECT DISTINCT BrandId FROM CTE