sql case 用法
程序员文章站
2022-06-05 12:12:04
...
sql case 用法
SELECT A.QFBH,A.XH, A.CCFCBZ,C.ZWCM,A0.QFSJ CCQFSJ,
(SELECT B.BZ FROM DTYW_FWRQFJCMX B WHERE B.QFJCXMBH = '0104'
AND B.QFJCXXBH = '0100024' AND B.QFBH = A.QFBH AND B.XH=A.XH ) QFSH ,
(SELECT B.BZ FROM DTYW_FWRQFJCMX B WHERE B.QFJCXMBH = '0104'
AND B.QFJCXXBH = '0100018' AND B.QFBH = A.QFBH AND B.XH=A.XH )
QFFMMC,
A.QFSJ FCQFSJ,
A.QFDD FCQFDD,
(SELECT CASE B.BZ WHEN '0' THEN '否' WHEN '1' THEN '是' WHEN '2' THEN '无' ELSE '' END FROM DTYW_FWRQFJCMX B
WHERE B.QFJCXMBH = '0104' AND B.QFJCXXBH = '0100021'
AND B.QFBH = A.QFBH AND B.XH=A.XH ) QFSFWH , -
(SELECT CASE B.SFFHYQ WHEN '0' THEN '否' WHEN '1' THEN '是' WHEN '2' THEN '无' ELSE '' END FROM DTYW_FWRQFJCMX B WHERE B.QFJCXMBH = '0104'
AND B.QFJCXXBH = '0100025' AND B.QFBH = A.QFBH AND B.XH=A.XH ) QFSHSL , --
(SELECT CASE B.SFFHYQ WHEN '0' THEN '否' WHEN '1' THEN '是' WHEN '2' THEN '无' ELSE '' END FROM DTYW_FWRQFJCMX B WHERE B.QFJCXMBH = '0104'
AND B.QFJCXXBH = '0100021' AND B.QFBH = A.QFBH AND B.XH=A.XH ) QFSHYY, -
(SELECT CASE B.SFFHYQ WHEN '0' THEN '否' WHEN '1' THEN '是' WHEN '2' THEN '无' ELSE '' END FROM DTYW_FWRQFJCMX B WHERE B.QFJCXMBH = '0104'
AND B.QFJCXXBH = '0100026' AND B.QFBH = A.QFBH AND B.XH=A.XH) QFSFFZ , -
(SELECT CASE B.SFFHYQ WHEN '0' THEN '否' WHEN '1' THEN '是' WHEN '2' THEN '无' ELSE '' END FROM DTYW_FWRQFJCMX B WHERE B.QFJCXMBH = '0103'
AND B.QFJCXXBH = '0100017' AND B.QFBH = A.QFBH AND B.XH=A.XH ) SFCZPWXW
FROM DTYW_FWRQFJC A,DTYW_FWRQFJC A0, DTYW_CBJBXX C WHERE A.CBBH = C.CBBH
AND A0.CCFCBZ='0' AND A.CCFCBZ='1' AND A.QFBH=A0.QFBH
上一篇: java 单元测试
下一篇: 定义一个方法求圆的面积