【问题标题】:Flexible Search query to select entity based on dependent灵活的搜索查询,根据依赖选择实体
【发布时间】:2018-02-26 17:49:25
【问题描述】:

我有一个有订单的用户。我想选择所有符合以下条件的用户:
1. 完全没有订单 2. 没有超过 x 日期的订单(因此,如果用户有 10 个订单,其中一个订单小于已过日期 - 我仍然需要这个用户。
3. 为结果添加更多条件

我已经这样做了,但它没有按我需要的方式工作。首先,我使用 LEFT join 加入所有订单,然后检查 - 如果订单大于过期日期 - 我不选择商品。最后一个“或”检查我自己已经很困惑了,不知道它在做什么(没有用户我们不能下订单)

select {c.pk}
from {User as c
left join Order as ord on {c.pk}={ord.user}}
where not exists
({{
  select {o.date} from {Order as o} where {o.date} >='24-Oct-2017'
}})
or {ord.user} is null

【问题讨论】:

    标签: java sql hybris


    【解决方案1】:

    在您的SubQuery 中缺少用户检查。添加{o.user} = {c.pk}

    【讨论】:

      猜你喜欢
      • 2019-06-06
      • 1970-01-01
      • 2022-11-29
      • 2014-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多