VVoVe:
Pauroso!!
Il case statement mi era nuovo!
Sei un mito!
Codice PHP:
$dati=mysql_query("select *,
case when year(date) = 2007 then sum(totale) else 0 end as '2007',
case when year(date) = 2008 then sum(totale) else 0 end as '2008',
case when year(date) = 2009 then sum(totale) else 0 end as '2009' FROM customer c, ordini o
WHERE c.cust_id = o.cust_id GROUP BY o.cust_id,year(date)") or die(mysql_error()) ;
L'unico problema è che non mi raggruppa per utente ovvero una riga per ogni anno.
Va bene il grosso è fatto!
Ti devo un paio di cene!