I need some help with a subquery. My test column sometimes comes back NULL and if so I want to filter those out of my results set.
My stored procedure looks like this
SELECT
    pl.Id AS Id,
    pl.Name AS Name,
    f.[Url] AS PrimaryImageUrl,
    up.Id AS MemberId,
    up.ProfessionalName,up.
    AvatarUrl,
    test = (SELECT 
                c.Id AS Id,
                c.Name AS Name,
                c.ContentImageUrl AS ImageUrl,
                c.Price AS Price,
                c.BPM AS BPM,
                f.Id AS 'File.Id',
                f.Url AS 'File.Name',
                TotalCount = COUNT (c.Id) OVER()
            FROM
                dbo.Content c
            INNER JOIN 
                dbo.PlayListContents pm ON c.Id = pm.ContentId 
                                        AND pm.PlaylistId = pl.Id
            INNER JOIN
                dbo.Files f ON c.ContentFileId = f.Id
            FOR JSON PATH),
    TotalCount = COUNT(1) OVER()
FROM
    dbo.Playlist pl
INNER JOIN 
    dbo.UserProfiles up ON pl.UserId = up.UserId
INNER JOIN 
    [dbo].[Files] AS f ON pl.[PrimaryImageId] = f.[Id]
WHERE
    (pl.Name LIKE '%' + @searchInput + '%')
    AND test IS NOT NULL
Why is this last line, AND test IS NOT NULL invalid? I need my result set to have all results with test being NOT NULL
 
     
     
    