簡體   English   中英

優化案例陳述的最佳方法是什么?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM