【发布时间】:2023-03-27 14:00:01
【问题描述】:
我必须忽略日期列中包含 null 的行。我该怎么做?
select s."SR Closed Date"::date,
s."Service Request Number",
a."Activity ID"
from sr_data_master s,
activity_master a
where s."Service Request Number" = a."Service Request Number"
and a."Service Request Number" is not null
and a."Service Tag" is not null
and a."Activity ID" is not null
and s."SR Closed Date"::date is not NULL
group by s."Service Request Number",
s."SR Closed Date"::date,
a."Activity ID";
我收到错误:
invalid input syntax for type date: "NULL"
【问题讨论】:
-
不相关,但是:如果您不使用任何聚合,为什么还要使用
group by? -
@a_horse_with_no_name 我认为 OP 不熟悉
DISTINCT,因此每列都使用GROUP BY。另外,看看 join 是如何完成的。
标签: sql postgresql date select null