你可以试试这个。
SELECT
col1,
CASE
WHEN col1 in ('val1', 'val2', 'val3')
THEN 'HELLO'
WHEN col1 in ('val4', 'val5', 'val6')
THEN 'WORLD'
END AS col2
FROM
--wherever you are getting your data from...
WHERE
col2 = :SEARCH
当您将 HELLO 传递给绑定变量时,它将返回如下所示的结果。
col1 col2
---- ----
val1 HELLO
val2 HELLO
val3 HELLO
如果你只想返回 col1,你可以做这样的事情
WITH SEARCH_RESULTS AS
(
SELECT
col1,
CASE
WHEN col1 in ('val1', 'val2', 'val3')
THEN 'HELLO'
WHEN col1 in ('val4', 'val5', 'val6')
THEN 'WORLD'
END AS col2
FROM
--wherever you are getting your data from...
WHERE
col2 = :SEARCH
)
SELECT col1 FROM SEARCH_RESULTS