0
I made the Select below only that it is not adding by the correct column, where I am missing?
In my structure I have the field dtConcat and the field dtConcat2 (these dates are different one is for order date and the other is for the date that effected the sale) he is adding the column dtConcat2 even I put in the select that I want the month and year of the column dtConcat
SELECT cat.id, cat.nome_vendedor, MONTH (dtConcat) AS mes, YEAR (dtConcat) AS ano,
SUM( IF( mov.tipo_venda = 'Atacado', mov.total, 0 ) ) AS Atacado
FROM lc_controle AS mov
INNER JOIN vendedor AS cat ON cat.id = mov.vendedor
where mov.exportado = 'Sim'
GROUP BY ano, mes, cat.nome_vendedor
ORDER BY nome_vendedor, ano, mes
Sometimes simple things get complicated. kkk Solved like this: SELECT DISTINCT cat.id, cat.salesperson, MONTH (dtConcat) AS dt_mes, YEAR (dtConcat) AS dt_year, SUM( IF( mov.dtConcat , mov.total, 0 ) AS Wholesale FROM lc_control AS mov INNER JOIN seller AS cat ON cat.id = mov.seller Where mov.exporter = 'Yes' GROUP BY cat.salesperson, dt_mes, dt_year ORDER BY salesperson, dtConcat
– Robert