`

sql case when

 
阅读更多
1:
select t.* ,b.NAME ISSUE_NAME  from FK_GUEST_INF t left join FK_ISSUE_INF b on b.ISSUE_ID=t.ISSUE_ID
where 1=1 and ((t.GUEST_CERT_TYPE='0' and (length(t.GUEST_CERT_NO) = 18 or length(t.GUEST_CERT_NO) = 15))
or (t.GUEST_CERT_TYPE = '1' and length(t.GUEST_CERT_NO) = 10)) and 2=2 order by t.MODIFY_T desc

2:
select case when t.GUEST_CERT_TYPE = '0' and length(t.GUEST_CERT_NO) = 18  OR  length(t.GUEST_CERT_NO) = 15 then  '1'
          when t.GUEST_CERT_TYPE = '1' and  length(t.GUEST_CERT_NO) = 10   then  '1'
         else  null   end GUEST_CERT_No ,
  t.*  from FK_GUEST_INF t

3:
select case when t.GUEST_CERT_TYPE = '0' and length(t.GUEST_CERT_NO) = 18  OR  length(t.GUEST_CERT_NO) = 15 then  GUEST_CERT_No --GUEST_CERT_No 是字段名
          when t.GUEST_CERT_TYPE = '1' and  length(t.GUEST_CERT_NO) = 10   then  GUEST_CERT_No
         else  null   end GUEST_CERT_No ,
  t.*  from FK_GUEST_INF t
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics