[英]What's the best way to optimize the case statements?
例如,我有三個case語句,我想將其值保存到變量中。
Select
Case when 1 then variable='123' else
case when 2 then variable='456' else
case when 3 then variable='123456'
from
table X where
some conditions ;
嘗試這個例如
Select x.field,
Case x.value
when 1 then '123'
when 2 then '456'
when 3 then '123456'
ELSE '789'
END AS variable
from
table X where
some conditions ;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.