SELECT 仅 SQL 中列为空的整行

SELECT only the whole row where the column is empty in SQL

如果我有以下示例 table,有什么方法可以只保留 "Closed Date" 列为空的行?在这个例子中,只有第二行有一个空的 "Closed Date" 列,第三和第四行没有。

Unique Key,Created Date,Month,Closed Date,Latitude,Longitude
32098276,12/1/2015 0:35,12,,40.78529363,-73.96933478,"(40.78529363449518, -73.96933477605721)"
32096105,11/30/2015 20:09,11,11/30/2015 20:09,40.62615508,-73.9606431,"(40.626155084398036, -73.96064310416676)"
32098405,11/30/2015 20:08,11,11/30/2015 20:08,40.6236074,-73.95914964,"(40.62360739765128, -73.95914964173129)"

我找到了这个,但这不是我要找的。有上师能开导吗?谢谢!

return empty row based on condition in sql server

您可以使用 IS NULL 过滤掉包含 NULL 值的记录:

SELECT *
FROM your_table
WHERE "Closed Date" IS NULL

请记住,带有 space 的列标识符是不好的做法。你应该使用类似 Closed_Date 的东西来避免引用。

您可以在 WHERE 子句中使用 IS NULL 条件:

SELECT *
FROM your_table
WHERE "Closed Date" IS NULL
SELECT *
FROM your_table
WHERE [Closed Date] IS NULL OR LTRIM(RTRIM([Closed Date])) = ''

SQL 服务器包含空字符串 ('') 的另一种方法

-->> SQL Server
SELECT * FROM your_table
WHERE [Closed Date] IS NULL OR [Closed Date] = ''

SELECT *
FROM your_table
WHERE ISNULL([Closed Date],'') = ''