有没有办法使用一个CASE
语句并返回 2 个不同的值?
以下查询有 2 个CASE
条件相同的语句。
select case when DA.value = 1
then da.Good else da.Bad end as Foo,
case when DA.value = 1
then ot.Good else ot.Bad end as Bar,
from someTable DA (nolock)
join otherTable OT (nolock) on OT...
where ...
无论如何,要指定该CASE
语句一次吗?
这样就不需要CASE
在条件发生变化时使两个语句保持同步?