3

我有如下 SQL 语句:

SELECT  ReturnDate
FROM    <joins>
WHERE   <conditions>

如何检查 ReturnDate 是否不为空?

4

4 回答 4

11

您可以使用CASEIS NULLIS NOT NULL):

SELECT CASE 
         WHEN ReturnDate IS NULL THEN 'It is null' 
         ELSE 'It is not null' 
       END AS IsItNull 
FROM   dbo.tablename ....

如果您需要过滤NULL/NOT NULL值,您还可以使用IS NOT NULL

WHERE ReturnDate IS NOT NULL  ...
于 2013-08-28T12:02:02.217 回答
0

Check the returnDate with the "Is Null"

于 2013-08-28T12:05:54.447 回答
0

如果您不想选择任何为空的记录,请使用以下内容:

SELECT  ReturnDate
FROM    <joins>
WHERE   ReturnDate IS NOT NULL AND <conditions>
于 2013-08-28T12:04:12.553 回答
-1

Try this query

SELECT  ReturnDate
FROM    joins
WHERE   conditions AND ReturnDate IS NOT NULL;
于 2013-08-28T12:06:09.700 回答