title: Spring - aggregation - feed activity
body: <p>I am working with spring and a Postgresql database.</p>
  
  <p>I have a Event table (exists differents types of events)
  I have a sql query to shows events to one user, similar like this:</p>
  
  <pre><code>@Query( value = "SELECT e FROM Event e WHERE e.user.id = :userId ORDER BY e.date DESC")
  Page&lt;Event&gt; findEvents(Long userId, Pageable pageable);
  </code></pre>
  
  <p>I would like to be able to aggregate events per type, when the dates are very close.
  Something like this: "Your photo has 10 likes"</p>
  
  <p>How do you solve these types of cases?</p>