我正在尝试使用 CONCAT_WS 生成主题行。但是,如果值为空,我想忽略分隔符。
请看这个查询
SELECT
CONCAT_WS(" ",
CASE WHEN total_attempts > 0 THEN
CONCAT( call_code_title , " - ", total_attempts, "<sup>",
CASE WHEN total_attempts = 2 THEN "nd"
WHEN total_attempts = 3 THEN "rd"
ELSE "th" END
, "</sup> attempt") ELSE call_code_title END
, "-", program_name) AS callSubject
FROM table
问题是当“program_name”为 NULL 时,字符串末尾总是会出现“-”。我不想连接“-” id program_name IS NULL
我怎么做?
谢谢