14
14
**SQL HAVING Example**
16
16
Take a look at the "Activities" table:
18
+---------+--------------+--------------+-------------+----------+
19
|Id |ActivityDate |ActivityType |ActivityCost | userID |
20
+=========+==============+==============+=============+==========+
21
| 1 |2011-01-02 | Sport |45 |131 |
22
+---------+--------------+--------------+-------------+----------+
23
| 2 |2011-01-02 | Art |10 |256 |
24
+---------+--------------+--------------+-------------+----------+
25
| 3 |2011-01-02 | Music |25 |022 |
26
+---------+--------------+--------------+-------------+----------+
27
| 4 |2011-01-02 | Food |125 |022 |
28
+---------+--------------+--------------+-------------+----------+
29
| 5 |2011-01-03 | Music |40 |131 |
30
+---------+--------------+--------------+-------------+----------+
31
| 6 |2011-01-03 | Food |20 |175 |
18
+---------+--------------+--------------+-------------+----------+
19
|Id |ActivityDate |ActivityType |ActivityCost | userID |
20
+=========+==============+==============+=============+==========+
21
| 1 |2011-01-02 | Sport |45 |131 |
22
+---------+--------------+--------------+-------------+----------+
23
| 2 |2011-01-02 | Art |10 |256 |
24
+---------+--------------+--------------+-------------+----------+
25
| 3 |2011-01-02 | Music |25 |022 |
26
+---------+--------------+--------------+-------------+----------+
27
| 4 |2011-01-02 | Food |125 |022 |
28
+---------+--------------+--------------+-------------+----------+
29
| 5 |2011-01-03 | Music |40 |131 |
30
+---------+--------------+--------------+-------------+----------+
31
| 6 |2011-01-03 | Food |20 |175 |
32
32
+---------+--------------+--------------+-------------+----------+
34
34
In order to find if any users have spent more than $100 on recreational activities, use the following SQL statement: ::