【问题标题】:Count(*) not showing null valuesCount(*) 不显示空值
【发布时间】:2019-10-09 22:57:25
【问题描述】:

我正在将 SAP 的 Hybris 用于一个小项目,但几乎成功了。我试图使用灵活搜索查找过去 7 天内订单数量为 0 的服务点位置。

这是我使用的 HAC 脚本:

select count(*), {PointOfService.name} from {Order left join PointOfService on {Order.pointOfService} = {PointOfService.pk}} where {creationTime} >= '2019-10-01' GROUP by {PointOfService.name} order by count(*)

脚本为我提供了每个单独的 PointOfService 的订单数量,但没有为我提供订单为“0”的 PointOfService 位置。我读到这是由于 count(*) 没有提供 NULL 值。有谁知道解决这个问题的方法吗?

【问题讨论】:

    标签: hybris flexible-search


    【解决方案1】:

    您的 where(creationTime) 中有一个 order 属性,因此如果没有特定服务点的订单,您将无法看到它。 类似的东西应该可以工作:

    select count(*),
    {ps.name}
    from {PointOfService as ps 
    left join Order as o on {o.pointOfService} = {ps.pk}}
    where count({o.pk}) == 0
    GROUP by {ps.name}
    

    【讨论】:

      猜你喜欢
      • 2011-07-23
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      • 2021-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多