Mysql
 sql >> Base de données >  >> RDS >> Mysql

MySQL :liste de la somme de plusieurs conditions dans une instruction SQL

Utilisez la commande mysql GROUP BY. Exemple de code totalement non testé :

select sum(x) as "sum", date as "date" from (
   select distinct a.id as ID, a.dur as x, DATE(FROM_UNIXTIME(rtime)) as date from b_c 
      inner join c on b_c.c_id = c.id 
      inner join a on c.id = a.c_id 
      inner join a_au on a.id = a_aud.id 
      inner join d on a_au.rev = d.rev 
      where 
         b_c.b_id = 30 and 
         a_au.stat != 1
) AS SubSelectTable
group by date;

Voir :http://dev.mysql.com /doc/refman/5.0/en/group-by-functions.html