Total sum of values of all dates

Asked

Viewed 46 times

2

How do I sum X values of a specific date and compare if the summed value 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;

1 answer

1


You can use the operator HAVING

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

I am no Mysql environment to test, any error tell me I edit here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.