在下面的查询中,我想在CASE的WHEN内以及在THEN之前添加AND条件,这是可能的吗? 6 U! h# _ n7 @) L ~, f6 m例如WHEN’r’AND table1.name =“ jones”然后’非常高’1 `; ]7 ^/ k1 V s% m
SELECT table1.id, table1.name, 2 I- v6 N! q, M; N1 O CASE table1.event" O) h% P' p6 A& M! a6 u4 K
WHEN 'r' THEN 'very high' N+ v& h: S$ K9 C4 \* @" G WHEN 't' THEN 'very low' . W i2 x$ L2 V/ H: z" ^* x ELSE (SELECT table2.risk FROM table2 WHERE table2.value 您可以像这样重写语句以完成所需的操作1 E" D: {$ m m \" f6 X
SELECT table1.id, table1.name, & c! W" \. T" i( r CASE ! m2 D4 w- R) t5 y \1 C' R' n WHEN table1.event = 'r' AND table1.name = 'jones' THEN 'very high' 5 \5 {. w) o. b WHEN table1.event = 't' AND table1.name = 'smith' THEN 'very low'; K+ B1 f6 ?& C& s" R
ELSE (SELECT table2.risk FROM table2 WHERE table2.value 请注意,您需要table1.event在CASE声明后删除。: `4 {$ G0 W# z4 c
这里的文件