我希望列中的所有空值都消失或不显示。 not值不适用于我的代码:
select A.EmpID [X_TMSHT_EMPID] ,convert (varchar,(A.[RecordDate]),1) [X_TMSHT_APPLY],
, (convert(varchar,(A.[RecordDate]),1) + ' ' +( MAX(IIF(ISNULL(CHARINDEX('O', A.[Entries], 0), -1) > 0,SUBSTRING(A.[Entries], LEN(A.[Entries]) - 5, 5), NULL)))) AS [TimeOut]
FROM Employees[B]
inner JOIN[DTR Upload] [A] ON B.EmployeeNo = A.EmpID
GROUP by B.LastName, B.FirstName, B.MiddleName, A.EmpID, A.[recordDate]
order by A.[recordDate] asc, B.LastName + ','+B.FirstName + ','+ B.MiddleName asc
答案 0 :(得分:0)
由于OP不能帮助处理任何数据样本,因此我了解OP希望删除包含NULL值的超时。因此,我只是使用派生表来筛选出具有NOT NULL值的超时。
SELECT * FROM (select A.EmpID [X_TMSHT_EMPID] ,convert (varchar,(A.[RecordDate]),1) [X_TMSHT_APPLY],
, (convert(varchar,(A.[RecordDate]),1) + ' ' +( MAX(IIF(ISNULL(CHARINDEX('O', A.[Entries], 0), -1) > 0,SUBSTRING(A.[Entries], LEN(A.[Entries]) - 5, 5), NULL)))) AS [TimeOut]
FROM Employees[B]
inner JOIN[DTR Upload] [A] ON B.EmployeeNo = A.EmpID
) AS d
WHERE d.TimeOut IS NOT NULL
GROUP by d.LastName, d.FirstName, d.MiddleName, d.EmpID, d.[recordDate]
order by d.[recordDate] asc