Total sum of values for all dates

2

How do I add X values to a specific date and compare if the value added is greater than 100?

/*
Data das consultas, e para cada data o somatório total dos valores, desde que este total seja maior do que 100.00. 
*/

SELECT 
    c.data AS 'Data Consul.', SUM(c.valor) AS 'Total dia'
FROM
    consulta c
WHERE
    c.valor > 100
GROUP BY c.data;
    
asked by anonymous 03.12.2014 / 19:03

1 answer

1

You can use the HAVING

SELECT 
    c.data AS 'DataConsul.', SUM(c.valor) AS TotalDia
FROM
    consulta c
GROUP BY 
    c.data
HAVING
    TotalDia > 100;

I have no MySQL environment to test, any error tell me what I edit here

    
03.12.2014 / 19:10