只返回EIA值,不返回EIA 2

(
  case
   when tc.name = 'EIA' then tor.value else null
  end
) as EIA,
(
  case
   when tc.name = 'EIA 2' then tor.value else null
  end
) as EIA2

这是这个表格结构
测试Tor值
EIA,EIA 2阳性,阳性
ID Name  EIA      EIA 2
1  John  POSITIVE no values??

最佳答案

试试这个:

(
  CASE
   WHEN tc.name IS NULL THEN '' WHEN tc.name = 'EIA' THEN tor.value
  END
) as EIA,
(
  CASE
   WHEN tc.name IS NULL THEN '' WHEN tc.name = 'EIA 2' THEN tor.value
  END
) as EIA2

07-26 00:51