Hybris关系型FlexibleSearch选择

时间:2019-05-16 12:18:19

标签: java hybris flexible-search

Hybris为同一基础商店的用户创建了多个购物车。如何选择每家商店的购物车多于一个的用户?

稍后,我将对他们进行排序并删除最旧的购物车。

Create

2 个答案:

答案 0 :(得分:2)

使用这个:

select {u.pk}, {b.pk}, count(distinct({c.pk})) 
from {
   user as u 
   join cart as c on {c.user} = {u.pk} 
   join basestore as b on {b.pk} = {c.store}
} 
group by {u.pk}, {b.pk} 
having count(distinct({c.pk})) > 1

答案 1 :(得分:1)

如果您使用保存的购物车和报价功能,那么可以考虑通过添加WHERE {c.saveTime} IS NULL AND {c.quoteReference} IS NULL

将其不包括在结果中
select {u.pk}, {b.pk}, count(distinct({c.pk})) 
from {
   user as u 
   join cart as c on {c.user} = {u.pk} 
   join basestore as b on {b.pk} = {c.store}
}

WHERE {c.saveTime} IS NULL AND {c.quoteReference} IS NULL
GROUP BY {u.pk}, {b.pk}
having count(distinct({c.pk})) > 1

更新:

要获取用户的唯一列表:

select {u.pk} 
from {...