vero... ma l'errore resta...
vero... ma l'errore resta...
Si, ma in questa subquery hai usato f_mail invece di f_email
Credo sia un'errore di distrazionecodice:select date_format(data_inizio,"%c") as mese, count(id) as app, sum(if(f_mail=1,1,0)) as flag_mail, sum(if(f_sms=1,1,0)) as flag_sms from agenda as t where year(data_inizio) = 2009 and id_cliente = 53 group by date_format(data_inizio,"%Y%m")![]()
Grazie per la correzione, ma con questa ho ancora lo stesso problema:
codice:select m.mese,coalesce(appuntamenti,0) as appuntamenti, coalesce(f_email,0) as flag_mail, coalesce(f_sms,0) as flag_sms from mesi as m left join ( select date_format(data_inizio,"%c") as mese, count(id) as appuntamenti, sum(if(f_email=1,1,0)) as flag_mail, sum(if(f_sms=1,1,0)) as flag_sms from agenda as t where year(data_inizio) = 2009 and id_cliente = 53 group by date_format(data_inizio,"%Y%m")) as tab on m.id = tab.mese
O magari spiega cosa vuoi fare. Quella query è totalmente insensata
Ciao e grazie per le risposte,
La tabella è questa:
http://img137.imageshack.us/img137/5499/38586974.png
e la tabella mesi:
http://img710.imageshack.us/img710/3317/qwe.png
Il dump della prima tabella: dump.
Vorrei tirar fuori tutti gli appuntamenti dalla tabella dell'anno 2009 e raggrupparli per mese e stampare zero se non ci sono appuntamenti.
codice:select m.mese,count(a.id) as quanti from mesi as m left join agenda as a on m.id = month(a.data_inizio) and year(a.data_inizio) = 2009 group by m.id order by m.id
Gentilissimo ed efficace come sempre![]()