我把我的明确要求写出来:
查询公司表bd_corp三个字段unitcode,unitname,sealeddate(封存日期)
首先查询公司编码开头是‘01’的
select unitcode,unitname,sealeddate from bd_corp where unitcode like '01%' ,会发现sealeddate一列有的行是有值的,
刚刚和一个人聊天,他用的sqlserver,他的业务是:“ 如果员工表内,婚姻状况F_Marriage字段非空的记录数为0。那么查询‘hello’和当前时间,否则只显示当前时间。
”
sql是:
if (
select COUNT(1) from AR_P_PersonBase where F_Marriage is not null ) = 0
select 'Hello',GETDATE()
else
select GETDATE()
截图: