我正在尝试为[W-9 Uploaded],[E& O Uploaded],[License Uploaded]显示真或假值。但它总是导致'不'。我永远不会得到'是'
select distinct tp.License_Exp_Date AS [License Expiration Date],
tp.EO_Exp_Date AS [E&O Expiration Date],
tp.Insurance_Exp_Date AS [Insurance Expiration Date],
tp.Brokerage_Company_Name AS [Agent Company],
pd.agent_id AS [Agent ID],
tp.Other_Phone AS [Agent Phone],
tu.First_Name + ' ' + tu.Last_Name AS [Agent Name],
[W-9 Uploaded] = CASE WHEN tr.User_Id = ta.User_ID and ta.Type_ID = 5 and ta.Sub_Type_ID = 4 and ta.IsDeleted = 0 THEN 'YES' ELSE 'NO' END,
[E&O Uploaded] = CASE WHEN tr.User_Id = ta.User_ID and ta.Type_ID = 5 and ta.Sub_Type_ID = 2 and ta.IsDeleted = 0 THEN 'YES' ELSE 'NO' END,
[License Uploaded] = CASE WHEN tp.Real_Estate_Sales_License IS NOT NULL AND LTRIM(RTRIM(Real_Estate_Sales_License)) <> '' AND NameOnLicense IS NOT NULL AND LTRIM(RTRIM(NameOnLicense)) <> '' AND License_Exp_Date IS NOT NULL AND GETDATE() < License_Exp_Date THEN 'YES' ELSE 'NO' END,
tu.Email AS [Agent Email]
from amp.dbo.tbl_profile tp (nolock)
left join amp.dbo.tbl_user tu (nolock)
on tp.Resnet_Agent_ID = tu.Resnet_Agent_ID
left join amp.dbo.tbl_Resume tr (nolock)
on tp.Resnet_Agent_ID= tr.Resnet_Agent_ID
left join amp.dbo.tbl_Attachment ta (nolock)
on tr.Resume_Id = ta.Business_ID
left join resnet_mysql.dbo.property_details pd
on pd.agent_id = tp.Resnet_Agent_ID
order by [License Expiration Date],[E&O Expiration Date] desc;
select * from amp.dbo.tbl_Attachment
where Type_ID = 5 and Sub_Type_ID =4 and IsDeleted = 0