I have to search in a data table of an advertiser, I need to group by advertiser according to the most viewed, separated by date.
I wanted to limit group by
, how?
Example table:
id visualizacoes data
485 19 20/05/2105
485 68 11/03/2105
121 45 05/04/2105
485 20 20/05/2105
370 37 26/05/2105
225 81 20/05/2105
485 75 07/03/2105
485 11 20/05/2105
485 46 20/05/2105
370 23 16/04/2105
370 15 09/05/2105
121 7 21/04/2105
680 10 20/05/2105
370 68 26/05/2105
370 92 26/05/2105
I want to group by id_anunciante
and add views with the same date, but I wanted to limit up to 3 records per advertiser.
Initial Query:
SELECT *, SUM(visualizacoes) AS total_visu
FROM anunciante
GROUP BY id,data