(1) SELECT  SYXH,ZYHM,YEXH,ISNULL(YETZ,'') AS YETZ ,RYKSMC,RYBQMC,HZXM FROM YG_BRSYK

如果列名数据等于NULL,那么ISNULL返回指定值' ',否则返回列值。最终,作为一个新列YETZ,出现在查询结果中

https://zhidao.baidu.com/question/1638118782051788900.html

(2)SELECT a.*,b.HZXM FROM YG_LIS_JCBYTK a(nolock) left join YG_BRSYK b(nolock)

on a.SYXH=b.SYXH and b.XTLB=1 and isnull(b.YEXH,0)=0 WHERE    a.JCRQ LIKE '20170202%'

当b.YEXH为Null的时候视为0,然后结果就是0=0,判断的话肯定是True
如果b.YEXH不为Null时候,相当于判断b.YEXH是否等于0

https://www.zybang.com/question/11d43f256fa2c16c8a44b879a1621153.html

(3) select oh.XH, b.GRBWMC, oh.HZXM, oh.ZYHM, b.GRSJ, oh.TBYSMC, oh.BQMC, oh.KSMC,
                       STUFF((SELECT ','+od.JCXJMC FROM  YG_DJ_JCBYTK od WHERE od.YGJLXH=oh.XH FOR XML PATH('')), 1, 1, '') AS JCXJMC,
                       case when ISNULL(oh.SHBZ, 0) = 0 then '未审核' when ISNULL(oh.SHBZ, 0) = 1 then '已审核'
                       when ISNULL(oh.SHBZ, 0) = 3 then '已作废' else '' end SHBZ,oh.MEMO,oh.SHMEMO FROM YG_YGJLK AS oh, YG_DJ_GRBWK b  where oh.XH=b.YGJLXH and oh.SYXH ='120337'

作用:删除指定长度的字符,并在指定的起点处插入另一组字符。

示例在第一个字符串 abcdef 中删除从第 2 个位置(字符 b)开始的三个字符,然后在删除的起始位置插入第二个字符串,从而创建并返回一个字符串

SELECT STUFF('abcdef', 2, 3, 'ijklmn')
GO

下面是结果集

aijklmnef

05-11 21:55