我有一列Status
,我想计算“ Pendings
”的行数和“ Finalized
”的行数
我尝试了这个:
Variable class = java.lang.Integer
Calculation = Sum
ResetType = Report
Increment type = None
Variable expression = $F{tbl_suspensao_status}.equals("Finalized") ? 0 : 1
但这没有用。
查询:
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}
最佳答案
select
sum(if(Status = "Pendings", 1, 0)) Pendings,
sum(if(Status = "Finalized", 1, 0)) Finalized
from table
或者
select
sum(Status = "Pendings") Pendings,
sum(Status = "Finalized") Finalized
from t1
Demo on sqlfiddle
关于mysql - 计算特定值IReport的行数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31858589/