Count in IReport

4

I have a report where I have the Status column, in this column I have the following statuses: Finished and Pending.

I created a variable and added it to the Sumary band and set the following properties:

Variable class = java.lang.Integer
Calculation = Sum
ResetType = Report
Increment type = None
Variable expression = $F{tbl_suspensao_status}.equals("Finalizado")  ? 0 : 1

But the result is always the total everything, its I have 2 Finalized and 2 Pending the result equals 4.

How can I correctly tell how many Statuses are Finished and how many are Pending?

Query:

SELECT
     tbl_suspensao.'codigoBeneficiario' AS tbl_suspensao_codigoBeneficiario,
     tbl_suspensao.'contrato' AS tbl_suspensao_contrato,
     tbl_suspensao.'data_fim' AS tbl_suspensao_data_fim,
     tbl_suspensao.'data_inicio' AS tbl_suspensao_data_inicio,
     tbl_suspensao.'status' AS tbl_suspensao_status,
     tbl_usuario.'nome' AS tbl_usuario_nome,
     tbl_suspensao.'nomeBeneficiario' AS tbl_suspensao_nomeBeneficiario
FROM
     'tbl_usuario' tbl_usuario INNER JOIN 'tbl_suspensao' tbl_suspensao ON tbl_usuario.'codigo' = tbl_suspensao.'usuario_id'
WHERE
 AND tbl_suspensao.'data_inicio' BETWEEN  $P{Data_Inicio} AND $P{Data_Fim}

GROUP BY
      tbl_suspensao_status
    
asked by anonymous 06.08.2015 / 15:52

1 answer

2

puts a column to do the type count like this:

    SELECT
     sum(1) as contador,
     tbl_suspensao.'codigoBeneficiario' AS tbl_suspensao_codigoBeneficiario,
     tbl_suspensao.'contrato' AS tbl_suspensao_contrato,
     tbl_suspensao.'data_fim' AS tbl_suspensao_data_fim,
     tbl_suspensao.'data_inicio' AS tbl_suspensao_data_inicio,
     tbl_suspensao.'status' AS tbl_suspensao_status,
     tbl_usuario.'nome' AS tbl_usuario_nome,
     tbl_suspensao.'nomeBeneficiario' AS tbl_suspensao_nomeBeneficiario
FROM
     'tbl_usuario' tbl_usuario INNER JOIN 'tbl_suspensao' tbl_suspensao ON tbl_usuario.'codigo' = tbl_suspensao.'usuario_id'
WHERE
 AND tbl_suspensao.'data_inicio' BETWEEN  $P{Data_Inicio} AND $P{Data_Fim}

GROUP BY
      tbl_suspensao_status;
So the Counter column gets your Field there in iReport.

    
10.09.2015 / 13:15