select Isnull(CertificateNo,'G检D类140130001')
from T_WeiTuoBook
where AreaId='3' and SubDepart='3' and DeviceType='D' and Isnumeric(Right(CertificateNo,7))=1
and substring(CertificateNo, 5,2) = right(year(getdate()),2)
select Isnull(CertificateNo,'G检D类140130001') from T_WeiTuoBook where AreaId='3' and SubDepart='3' and DeviceType='D' and Isnumeric(Right(CertificateNo,7))=1 and substring(CertificateNo, 5,2) = right(year(getdate()),2) 当CertificateNo没有最大值时,我想把‘G检D类14
select Isnull((select CertificateNo from T_WeiTuoBook where AreaId='3' and SubDepart='3' and DeviceType='D' and Isnumeric(Right(CertificateNo,7))=1
and substring(CertificateNo, 5,2) = right(year(getdate()),2)),'G检D类140130001')