This query gives me the total attendance of two parliamentary groups (eg PS, PSD) between two dates:
SELECT DISTINCT a.partido,
(SELECT COUNT(presencas.assiduidade) FROM presencas, reunioes
WHERE presencas.assiduidade = 'Presença (P)'
AND presencas.id_deputado = a.id_deputado
AND reunioes.data_reuniao BETWEEN '2015-10-23' AND '2017-08-30'
AND presencas.id_reuniao = reunioes.id_reuniao) AS total_presencas
FROM deputados a WHERE a.partido IN ('PS','PSD');
However,Iwantedtoaddthetotalattendancebyparliamentarygroup(eg:PS,PSD)betweendates,butthefollowingquerygivesmeerror:
SELECTDISTINCTa.partido,(SELECTSUM(COUNT(presencas.assiduidade))FROMpresencas,reunioesWHEREpresencas.assiduidade='Presença(P)'ANDpresencas.id_deputado=a.id_deputadoANDreunioes.data_reuniaoBETWEEN'2015-10-23'AND'2017-08-30'ANDpresencas.id_reuniao=reunioes.id_reuniao)astotal_presencasFROMdeputadosaWHEREa.partidoIN('PS','PSD');
IthinkthiserrorisduetothetwofunctionstogetherSUM|COUNT.
1111-Invaliduseofgroupfunction
Canyouhelpme?Myintentionistodosomethinglike: