SQL Select Having
What the difference? between `where` and `having`
We could use `having` function to select data with condition of `count` column value
id | client | tarif | date_achat |
1 | Pierre | 102 | 2012-10-23 |
2 | Simon | 47 | 2012-10-27 |
3 | Marie | 18 | 2012-11-05 |
4 | Marie | 20 | 2012-11-14 |
5 | Pierre | 160 | 2012-12-03 |
And here is the resultSELECT client, SUM(tarif) FROM achat GROUP BY client HAVING SUM(tarif) > 40
client | SUM(tarif) |
Pierre | 262 |
Simon | 47 |