SQL查询中的Cast函数

时间:2017-11-02 22:33:06

标签: sql

我正在尝试在CAST()datetime功能上使用NULL功能。

我的查询是这样的:

where  [closed_at] = '' or  Cast ([closed_at]  as datetime) > = '09-01-2011 00:00' 

     and  [class_name] in ('Job' ,'Education');

1 个答案:

答案 0 :(得分:0)

您将使用IS NULL条件

where ([closed_at] is NULL or Cast ([closed_at] as datetime) > = '09-01-2011 00:00') and  [class_name] in ('Job' ,'Education');

where Cast (ISNULL([closed_at],'09-01-2011 00:00') as datetime) > = '09-01-2011 00:00') and  [class_name] in ('Job' ,'Education');