我有如下 SQL 语句:
SELECT ReturnDate
FROM <joins>
WHERE <conditions>
如何检查 ReturnDate 是否不为空?
我有如下 SQL 语句:
SELECT ReturnDate
FROM <joins>
WHERE <conditions>
如何检查 ReturnDate 是否不为空?
您可以使用CASE
(IS NULL
或IS 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 ...
Check the returnDate with the "Is Null"
如果您不想选择任何为空的记录,请使用以下内容:
SELECT ReturnDate
FROM <joins>
WHERE ReturnDate IS NOT NULL AND <conditions>
Try this query
SELECT ReturnDate
FROM joins
WHERE conditions AND ReturnDate IS NOT NULL;