In function CONCAT
, you pass CONCAT(Parametro A, PArametro B, Parametro C.....)
example: CONCAT(last_name, '''s job category is ')
where will display:
Hall’s job Category is SA_REP'
Your select is trying to join COMPLETED , RECEIVED and AUTHORIZED.....
SELECT
b.numero_contrato as name, CONCAT(
sum(CASE WHEN a.status = 'Concluida' THEN 1 ELSE 0 END) AS concluidas,
sum(CASE WHEN a.status = 'Recebida' THEN 1 ELSE 0 END) AS recebidas,
sum(CASE WHEN a.status = 'Autorizada' THEN 1 ELSE 0 END) AS autorizadas) as dados
fROM controle_contratos a, contratos b where a.id_contrato = b.id_contrato and b.ativo = 1 group by b.numero_contrato
I believe the sentence below will help you:
SELECT
NAME, SUM(CONCLUIDAS), SUM(RECEBIDAS), SUM(AUTORIZADAS)
FROM (
SELECT
b.numero_contrato as name,
CASE WHEN a.status = 'Concluida' THEN 1 ELSE 0 END as concluidas,
CASE WHEN a.status = 'Recebida' THEN 1 ELSE 0 END AS recebidas,
CASE WHEN a.status = 'Autorizada' THEN 1 ELSE 0 END AS autorizadas
fROM
controle_contratos a,
contratos b
where
a.id_contrato = b.id_contrato
and b.ativo = 1
group by b.numero_contrato
)
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat according to the documentation
concat
receives a comma-separated list of values, which is not supported incase
. explain better what you want to do by concatenating sums of different values, it doesn’t make much sense that– Ricardo Pontual