SELECT
'https://xxxxxx/' + CONVERT(VARCHAR(10), [AnnouncementID]) AS 'URL',
[Status] AS 'Code',
[Subject] AS 'Text',
(CASE
WHEN LEN([Subject]) > 500
THEN SUBSTRING([Subject], 0, 500) + '...'
ELSE [Subject] END)
AS 'ShortText'
FROM
[Announcement]
WHERE
[Public] = 1
AND [Enable] = 1
AND GETDATE() BETWEEN [ActiveFrom] AND [ActiveTo]
ORDER BY
[Status] ASC, [ActiveFrom] ASC
This query returns something like:
Url Code Text ShortText
-------------------------------------------------
https://xxxxxx/2 Enable Text Text
https://xxxxxx/1 Critical Text Text
I would like to Automatic change the text in [Code]
.
- If Critical -> RED
- If Enabled -> YELLOW
How can I rewrite my query string above?