如何只汇总流中的正数?

时间:2018-01-05 16:19:14

标签: java

迭代时我在流中有列表值我需要检查该值是否为负,如果否定返回零或者返回相同的值

以下是我的代码

              {
                       Inventory .stream().
                       map.(inventory.value).sum;
                 }

1 个答案:

答案 0 :(得分:1)

您可以使用select count(distinct l.user) as likes_count, count(distinct c.id) as comentarios_count from posts p left join likes l on l.post = p.id left join comentarios c on c.foto = p.id and c.delete = 0 group by p.id 。您必须将它们映射为整数,大概是:

Math.min