title: How to count records from database and put them into List<Long>,each row represent by the letter?
body: <p>I need to take values from a database and put them into a <code>List&lt;Long&gt;</code>. I made a native query but it doesn't work correctly. Here's a picture of the column on my database:</p>
  <p><a href="https://i.stack.imgur.com/7rQRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7rQRG.png" alt="columnInDb" /></a></p>
  <p>I need to count the same statuses (&quot;W&quot; and &quot;I&quot; represent the same status but are represented by another letter).
  I prepared a query as shown below:</p>
  <pre><code>@Query(value = &quot;SELECT COUNT(CASE WHEN table.status = 'W' OR  table.status = 'I' THEN 1 ELSE 0 END) AS WI,&quot;
              &quot; COUNT(CASE WHEN table.status = 'S' THEN 1 ELSE 0 END) AS S,&quot; +
              &quot; COUNT(CASE WHEN table.status = 'N' THEN 1 ELSE 0 END) AS N,&quot; +
              &quot; COUNT(CASE WHEN table.status = 'D' THEN 1 ELSE 0 END) AS D,&quot; +
              &quot; COUNT(CASE WHEN table.status = 'E' THEN 1 ELSE 0 END) AS E,&quot; +
              &quot; COUNT(CASE WHEN table.status = 'T' THEN 1 ELSE 0 END) AS T&quot; +
              &quot; FROM table.table table&quot; +
              &quot; WHERE table.id = :id&quot;+
              &quot; GROUP BY table.status&quot; +
              &quot; ORDER BY table.status ASC&quot;,
              nativeQuery = true)
      List&lt;Long&gt; query1 (Long id);
  </code></pre>
  <p>But it's not working correctly. When I run the query I get the following result:</p>
  <p><a href="https://i.stack.imgur.com/6KdMZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6KdMZ.png" alt="result" /></a></p>
  <p>But it should be {2(D),2(E),1(N),1(S),1(T),3(W and I).
  Do you have any idea on how to fix it?</p>