SELECT list is not in GROUP BY clause and contains nonaggregated column 'conteggio.data'
<p>I have this query :</p>

<pre><code>$sql_errori_doppie="select doc_doppio,count(*) as doppie,data
from(select data,doc_doppio,count(*) as num_lezioni_doppie
from(SELECT cou_id, DATE_FORMAT(FROM_UNIXTIME(cou_ts_1), '%d-%m-%Y %h:%i') as data ,cou_ins_1 as doc_doppio
FROM courses where cou_type='mot' and cou_ins_1&lt;&gt;0
and (substr(DATE_FORMAT(FROM_UNIXTIME(cou_ts_1), '%Y-%d-%m'),1,4))=".$q. " 
UNION ALL 
SELECT cou_id, DATE_FORMAT(FROM_UNIXTIME(cou_ts_2), '%d-%m-%Y %h:%i'),cou_ins_2 FROM courses where cou_type='mot' 
and cou_ins_2&lt;&gt;0 and (substr(DATE_FORMAT(FROM_UNIXTIME(cou_ts_1), '%Y-%d-%m'),1,4))=".$q. " 
UNION ALL 
SELECT cou_id, DATE_FORMAT(FROM_UNIXTIME(cou_ts_3), '%d-%m-%Y %h:%i'),cou_ins_3 FROM courses where cou_type='mot' 
and cou_ins_3&lt;&gt;0 and (substr(DATE_FORMAT(FROM_UNIXTIME(cou_ts_1), '%Y-%d-%m'),1,4))=".$q. " 
)
as da group by data,doc_doppio
having num_lezioni_doppie&gt;1
)
as conteggio group by doc_doppio;";
</code></pre>

<p>When I try to do it I Have this message:</p>

<blockquote>
  <p>SELECT list is not in GROUP BY clause and contains nonaggregated
  column 'conteggio.data' which is not functionally dependent on columns
  in GROUP BY clause; this is incompatible with
  sql_mode=only_full_group_by</p>
</blockquote>

<p>How to change the query or the only_full_group_by parameter?</p>