Query Mysql does not return error or result

2

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
    
asked by anonymous 30.04.2014 / 20:28

2 answers

1

Try this below:

SELECT a.data_proposta, 
       a.source_code, 
       Sum(b.custo)             AS custo, 
       Count(a.data_proposta)          AS propostas, 
       Sum(IF(precog_fk <> 9, 1, 0)) AS validas 
FROM   propostas a, midias b
       a.data_proposta(+) = b.data
GROUP  BY a.data_proposta
    
30.04.2014 / 21:00
0

The problem can be in the format of the date field, as you did not pass the table structure, it is difficult to identify the problem, see if that would solve your case:

SELECT DATE_FORMAT(data_proposta, '%d/%m/%Y') as data_proposta, 
       propostas.source_code, 
       Sum(midias.custo) AS custo, 
       Count(DATE_FORMAT(data_proposta, '%Y-%m-%d')) AS propostas, 
       Sum(IF(precog_fk <> 9, 1, 0)) AS validas 
FROM   propostas 
       LEFT JOIN midias 
              ON data_proposta = midias.data 
               where custo > 0
GROUP  BY data_proposta, propostas.source_code
    
17.11.2016 / 13:40