Re: contare e sommare dopo JOIN
È abbastanza semplice, su usa GROUP BY el.id per dire che vuole tutte rows per lo stesso cd, aggregato come uno. Poi è possibile usare funzioni speciali che operare su un gruppo di rows.
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
SELECT el.*, SUM(vot.numero) AS somma, AVG(vot.numero) AS media, COUNT(*) AS voti_totale FROM elenco_cd el
INNER JOIN voti_cd vot
ON vot.id_cd = el.id
GROUP BY el.id
Subject
Views
Written By
Posted
4523
November 13, 2009 02:59PM
Re: contare e sommare dopo JOIN
2818
November 21, 2009 09:03PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.