Query in HQL using Hibernate

0

How to make a query to return the result to below in HQL

Result

| quantidade | quantidade erro |   desc   |

|     2      |         1       |  TESTE 1 |
|     3      |         2       |  TESTE 2 |
|     1      |         1       |  TESTE 3 |

Table

| DESC    |  ERRO |

| TESTE 1 |   0   |
| TESTE 1 |   1   |
| TESTE 2 |   1   |
| TESTE 2 |   0   |
| TESTE 2 |   1   |
| TESTE 3 |   1   |
    
asked by anonymous 06.07.2015 / 16:38

1 answer

1

You need to group the data by Description and make a count ( count ) for the grouped quantity, then a SUM to count the number of errors - ERRO , and at the end append the description:

SELECT COUNT(*) as quantidade, SUM(ERRO) as quantidadeErro, desc
FROM tabela
GROUP BY DESC
    
06.07.2015 / 16:57