第一種 格式 : 簡單case函式 :
格式說明
case 列名
when 條件值1 then 選擇項1
when 條件值2 then 選項2.......
else 預設值 end
select
case job_level
when '1' then '1111'
when '2' then '1111'
when '3' then '1111'
else 'eee' end
from dbo.employee
第二種 格式 :case搜尋函式case isneed
when '1' then '10'
when '0' then '20'
end as totalfreight
格式說明
case
when 列名= 條件值1 then 選擇項1
when 列名=條件值2 then 選項2.......
else 預設值 end
update employee
set e_wage =
case
when job_level = '1' then e_wage*1.97
when job_level = '2' then e_wage*1.07
when job_level = '3' then e_wage*1.06
else e_wage*1.05
end
比較: 兩種格式,可以實現相同的功能。province =
case
when dccity = '商丘' then '河南'
when dccity <> '商丘' then '非河南'
end,
簡單case函式的寫法相對比較簡潔,但是和case搜尋函式相比,功能方面會有些限制,比如寫判斷式。還有乙個需要注意的問題,case函式只返回第乙個符合條件的 值,剩下的case部分將會被自動忽略。
想法是
如果order=81的 stats !=1的情況下,不會查詢order=129的資料,反之,當order=81的stats=1,就需要顯示order=129的資料
**:
select * from syscon where number=3 and
(case when 1 =(select [stats] from dbo.syscon where [order]=81) then 1
case when 1 != (select [stats] from dbo.syscon where [order]=81) and [order] != 129 then 1
else 0 end
)=1order by id
FIELD SYMBOLS的兩種用法
第一種,把fs當做乙個泛型,什麼東西都可以放進去 data begin of man,name type str,20 type c,height type i,end of man.data a man like man.a man name 阿勇 a man f a man height 171...
Android Intent的兩種用法
intent是android元件之一,是用於連線四大元件的乙個比較重要的部分。intent有兩種用法 一種是顯式intent,如果用於啟用activity就這樣寫 intent intent new intent this,testactivity.class startactivity 一種是隱式...
Handler的兩種用法
android 為了執行緒安全,只允許在主線程中修改ui,如果想在子執行緒中更改ui,可以使用handler.用法一 在子執行緒中傳送更新資訊 message msg message.obtain msg.what 1 bundle data new bundle data.putstring so...