How can I get a field I want to make COUNT
work?
select PVN.NFNum, COUNT(distinct CtrlCargaNum) as Qtd from CTRL_CARGA cc
INNER JOIN PED_VENDA_NOTA_FISCAL PVN ON cc.EmpCod = PVN.EmpCod
where cc.CtrlCargaData between '2018-01-01' and '2018-01-04' and cc.EmpCod = '01.01';
It gives the following error in MySQL Server
:
Column 'PED_VENDA_NOTA_FISCAL.NFNum' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.