I'm doing a reporting system and the bank will have, for example:
> - visualizacoes | 300
> - clicks | 20
> - data | 2015-06-03
> - visualizacoes | 230
> - clicks | 3
> - data | 2015-06-03
> - visualizacoes | 340
> - clicks | 10
> - data | 2015-07-01
So my problem is, it's going to have 2 records or more of the date (Ms) the same as in the example above that has two with the month 06 . I need to add the clicks and views of the same month and display 1 result only (already added) in query
.
I have the code
$relatorios = $this->db->query("SELECT visualizacoes, clicks, MONTH(data) AS mes FROM relatorio WHERE YEAR(data) = '".date('Y')."' ORDER BY data ASC");
But this is only organizing to do the report of the current year, but I have no idea how to put something to add the same month.