SELECT *,CASE
WHEN 差距 > 0 THEN
'有效' ELSE '失效'
END AS 判断 FROM (SELECT *, datediff(DAY, GETDATE(),结束时间) 差距 FROM [dbo].[供应商证书])
END AS 判断 FROM (SELECT *, datediff(DAY, GETDATE(),结束时间) 差距 FROM [dbo].[供应商证书]) A