1.替换对应字段中内容
replace(TB1.Zy,' ','') as JJ
2.截取字段
subString(BNum,1,2),subString(BNum,3,2)
3.类型转换
convert(varchar(50),'-'),convert(varchar(50),'20')
4.判断字段内容是否为空
S.BNum is null or S.BNum=''
5.条件语句case when ...then ...else...end
Case when TD.ID in ('03','04') and (S.BNum is null or S.BNum='') then (convert(varchar(50),'20') + subString(TD.Nd,1,2) + convert(varchar(50),'-') ) else (convert(varchar(50),'20') + convert(varchar(50),'-') + subString(BNum,5,2)) end