I have 5 tables in which each of them has data that needs to be displayed grouped by date. Proposals are grouped by date, quantity of proposals, value of proposals, media, amount invested, number of clicks, code (source_code) and if it is denied or accepted. the result would be something like this:
data_proposta | source_code | custo(total por data) | midia | cliques | impressoes | custo | negadas | aceitas
I have a table called proposal, another media (which brings clicks, value, impressions), precog (valid or not) and source_code.
Each proposal is saved in a new proposal table row and this query makes a COUNT()
in the number of proposals, separated by proposals denied and accepted with COUNT()
tbm.
Brings from the media table the number of clicks, amount of cost grouped by date based on source_code
.
I'm trying to make a select
in MySQL and phpMyAdmin simply does not return any error and also does not display the result.
Look at my query :
SELECT data_proposta,
propostas.source_code,
Sum(midias.custo) AS custo,
Count(data_proposta) AS propostas,
Sum(IF(precog_fk <> 9, 1, 0)) AS validas
FROM propostas
LEFT JOIN midias
ON 'data_proposta' = 'midias'.'data'
GROUP BY data_proposta
LIMIT 0, 1