title: Java 8 lambda sum, count and group by
body: <pre><code>Select sum(paidAmount), count(paidAmount), classificationName,
  From tableA
  Group by classificationName;
  </code></pre>
  
  <p>How can i do this in Java 8 using streams and collectors?</p>
  
  <p>Java8:</p>
  
  <pre><code>lineItemList.stream()
              .collect(Collectors.groupingBy(Bucket::getBucketName,
                         Collectors.reducing(BigDecimal.ZERO,
                                             Bucket::getPaidAmount,
                                             BigDecimal::add)))
  </code></pre>
  
  <p>This gives me sum and group by. But how can I also get count on the group name ?</p>
  
  <p>Expectation is :</p>
  
  <pre><code>100, 2, classname1 
  50, 1, classname2
  150, 3, classname3
  </code></pre>