用例将日期转换为文本以显示null
首先,我是一个SQL婴儿,所以请耐心等待我。我正在尝试查询一张桌子上有放电日期的桌子。我想显示出排出原因或日期为null的记录。当我编写查询时,我尝试了一个案例语句和在哪里确定任何案例。运行查询时我没有结果。
/****** selectTopnrows命令的脚本来自ssms ******/ 选择[Eockey]
-- ,[Division Code]
-- ,[Division]
,[FacilityOrgKey]
,[Facility Code]
,[Facility Name]
,[DMH ID]
,[Consumer Full Name]
,[Open Admission]
--,[ProviderSiteOrgKey]
--,[Provider Site]
,[Local Chart Number]
--,[Initial Contact Date]
,[Admission Date]
,[Admission Reason Code]
-- ,[Admission Reason]
,[Admission Comment]
-- ,[Referral Source Code]
,[Referral Source]
-- ,[ReferralOfficeOrgKey]
-- ,[Referral Office]
,[Discharge Date]
,[Discharge Reason Code]
,[Discharge Reason]
,[Discharge Comment]
-- ,[Follow Up Type Code]
-- ,[Follow Up Type]
-- ,[Referral Given]
-- ,[ReferredToOrgKey]
-- ,[Referred To]
-- ,[Date Added]
-- ,[Added By]
-- ,[Date Modified]
-- ,[Modified By]
-- ,[DivisionKey]
-- ,[EOCAdmissionReasonKey]
-- ,[EOCDischargeReasonKey]
-- ,[EOCFollowupTypeKey]
-- ,[ReferralSourceTypeKey]
--case when convert(DATE, Discharge Date) is Null then '' End as [DC Date]
FROM [Data_Central].[CIMOR].[EpisodeOfCare]
Where [Facility Code] in ('005','009','026')
and [Discharge Reason] like '%Null%'
First I am a SQL baby so please be patient with me. I am trying to query a table with discharge dates in the table. I want to display records where Discharge Reason or date is null. When I write the query I tried both a case statement and where statement to identify any cases. I get no results when I run the query.
/****** Script for SelectTopNRows command from SSMS ******/
SELECT [EOCKey]
-- ,[Division Code]
-- ,[Division]
,[FacilityOrgKey]
,[Facility Code]
,[Facility Name]
,[DMH ID]
,[Consumer Full Name]
,[Open Admission]
--,[ProviderSiteOrgKey]
--,[Provider Site]
,[Local Chart Number]
--,[Initial Contact Date]
,[Admission Date]
,[Admission Reason Code]
-- ,[Admission Reason]
,[Admission Comment]
-- ,[Referral Source Code]
,[Referral Source]
-- ,[ReferralOfficeOrgKey]
-- ,[Referral Office]
,[Discharge Date]
,[Discharge Reason Code]
,[Discharge Reason]
,[Discharge Comment]
-- ,[Follow Up Type Code]
-- ,[Follow Up Type]
-- ,[Referral Given]
-- ,[ReferredToOrgKey]
-- ,[Referred To]
-- ,[Date Added]
-- ,[Added By]
-- ,[Date Modified]
-- ,[Modified By]
-- ,[DivisionKey]
-- ,[EOCAdmissionReasonKey]
-- ,[EOCDischargeReasonKey]
-- ,[EOCFollowupTypeKey]
-- ,[ReferralSourceTypeKey]
--case when convert(DATE, Discharge Date) is Null then '' End as [DC Date]
FROM [Data_Central].[CIMOR].[EpisodeOfCare]
Where [Facility Code] in ('005','009','026')
and [Discharge Reason] like '%Null%'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以直接使用为null-
You can directly use IS NULL -