case when用法(涉敏字段查詢)

2021-09-29 01:45:33 字數 2644 閱讀 7366

--查詢光纜

select t.name,

t.length,

t.gatherdate,

(case

when t.category =

0 then

'一'when t.category =

3 then

'二'when t.category =

4 then

'三'when t.category =

5 then

'四'when t.category =

6 then

'五'when t.category =

7 then

'六'when t.category =

8 then

'七'when t.category =

9 then

'八'else

'九' end) 光纜層級,

t.domain_

from giscablesection tt, giscable t

where tt.cableid = t.id

涉敏感字段 when 的表示式只能是 數字 如 大於0 等而不能是 普通的查詢

select

'***系統' 系統名稱,

'國***' 廠家,

(select og.name from pm_organization og where og.id = p.organizationid )所屬公司,

(select d.name from t_department d where d.id = p.ahcm_department_id ) 所屬部門,

p.name 使用人,

p.username 賬號名,

(case when p.ahcm_count_type =

0 then '移動員工'

else

(case when

p.ahcm_count_type =

1 then '代維員工'

else

'施工方' end) end) 賬號型別,

p.jobno 員工編號,

/* ( select '工單管***許可權,'||'纖***許可權,'||'管線系統許可權,'||'綜合業務接入區許可權,'||wm_concat(to_char(ro.name)) from sys_user_role ur,sys_role ro

where ur.role_id = ro.id and ur.user_id = p.id and rownum <= 10) 許可權列表,*/

p.expireddate 賬號使用期限,

(case

when

(select

count

(p1 .name)

from pm_user p1 where p1.id=p.id and

(p.name like '%吳%' or p.name like '%李%'))

>

0 then

'是'else

'否' end) 是否涉敏

from pm_user p

where p.

status

=80200026

敏感字部隊,軍隊,武警,武裝警察,公安,****局,國安局

select

*from

(select

'trans01r37' ruler_seq,

cp.sharding_id sharding_id,cp.

int_id id ,cp.

tubehole_no name , cp.parent_id ,

(case

when int_id

= parent_id then

'管孔的id和parent_id相同'

else

'' end) notes ,rownum rn

from irms.

view_trans01r24 cp) cp1 -- trans01r37 用 view_trans01r24 檢視

where cp1.notes is not null

select

*from

(select

'trans07r02' ruler_seq,cp.

sharding_id sharding_id ,

cp.region_id,cp.

int_id id,

cp.zh_label name ,

(case

when zh_label is not null then

'該站點下無機房'

else

'' end) notes,rownum rn

from irms.

view_trans01r43 cp -- trans07r02 用 view_trans01r43 檢視

where cp.int_id not in

(select room.tml_id from cm_facility room where room.spec_id=

1010100001

)) cp1 where cp1.notes is not null

oracle之 case when 的用法

oracle case when的用法 select col1,col2,case when col3 1 and col3 2 then 1 when col3 2 and col3 3 then 2 when col3 3 and col3 4 then 3 else 4 end mylevel...

CASE WHEN的簡單用法

在sql中判斷非a即b類似的表示式時,可以用 case when 句式來判斷。when judgeexpression as not a is b,語法 case when conditionthen result when else result end case 子句可以用於任何表示式可以有效存...

MySQL中Case When用法詳解

最近,在學習hive基礎知識時,遇到了遇到了case when else end語法,以前學習mysql時忽略了這部分知識點,現總結一下相關的知識給大家。首先練習乙個例子如下 一 學生課程成績統計 1 建表 use hivedemo create table course id int,sid in...