mardi 5 mai 2015

SQL Server 2012: Select literal and compare to the literal in Where

So, basically, in my query, I want to have a statuses column that will contain 1 or more statuses based on certain criteria. A user should be able to filter/search also on those status messages in that column. I'm not sure on the syntax to make this happen.

This selects 0 to 2 status divs in my column, which I display as is.

Here's theoretically what I want to happen:

Select fields, (select CASE WHEN root_directory IS NULL THEN '<div class="gray status">Unbuilt</div>' ELSE '' END + ' ' + (select top(1) CASE WHEN isnull(payment_received,0) = 1 THEN '' ELSE '<div class="red status">Unpaid</div>' END
FROM invoice C
WHERE C.id = B.id) as statuses
FROM table
WHERE statuses LIKE '%Unbuilt%'

Thoughts on how to WHERE LIKE my statuses column?

Thanks.

Aucun commentaire:

Enregistrer un commentaire