Můj nejdelší SQL dotaz
No ona to není taková bomba, ale přesto z něj mám radost. Ušetří mi spoustu práce a ani jsem nepočítal s tím, že půjde udělat. Je to vlastně 6 dotazů v jednom. Úžasné!
select * from (
select test, poceto/pocetn as prumer from (
select * from(select concat(jmeno,'-',id,'-',id2) as test, count(pocet) as poceto from komentare where uroven>0 and pocet>1 and DATE_ADD(datum2,INTERVAL 12 MONTH)>NOW() and jmeno not like '%*%' group by test) as x where x.poceto>5
)as q LEFT JOIN (
select * from(select concat(jmeno,'-',id,'-',id2) as test2, count(pocet) as pocetn from komentare where uroven>0 and DATE_ADD(datum2,INTERVAL 12 MONTH)>NOW() and jmeno not like '%*%' group by test2) as y where y.pocetn>5
) as w ON q.test=w.test2
)as konec where konec.prumer>=0.2