You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each row contains information about the amount of one bill and the customer associated with it.
21
+
</pre>
22
+
23
+
<p> </p>
24
+
25
+
<p>Write an SQL query to report the number of customers who had <strong>at least one</strong> bill with an amount <strong>strictly greater</strong> than <code>500</code>.</p>
26
+
27
+
<p>The query result format is in the following example.</p>
28
+
29
+
<p> </p>
30
+
<p><strong>Example 1:</strong></p>
31
+
32
+
<pre>
33
+
<strong>Input:</strong>
34
+
Store table:
35
+
+---------+-------------+--------+
36
+
| bill_id | customer_id | amount |
37
+
+---------+-------------+--------+
38
+
| 6 | 1 | 549 |
39
+
| 8 | 1 | 834 |
40
+
| 4 | 2 | 394 |
41
+
| 11 | 3 | 657 |
42
+
| 13 | 3 | 257 |
43
+
+---------+-------------+--------+
44
+
<strong>Output:</strong>
45
+
+------------+
46
+
| rich_count |
47
+
+------------+
48
+
| 2 |
49
+
+------------+
50
+
<strong>Explanation:</strong>
51
+
Customer 1 has two bills with amounts strictly greater than 500.
52
+
Customer 2 does not have any bills with an amount strictly greater than 500.
53
+
Customer 3 has one bill with an amount strictly greater than 500.
Each row contains information about the amount of one bill and the customer associated with it.
19
+
</pre>
20
+
21
+
<p> </p>
22
+
23
+
<p>Write an SQL query to report the number of customers who had <strong>at least one</strong> bill with an amount <strong>strictly greater</strong> than <code>500</code>.</p>
24
+
25
+
<p>The query result format is in the following example.</p>
26
+
27
+
<p> </p>
28
+
<p><strong>Example 1:</strong></p>
29
+
30
+
<pre>
31
+
<strong>Input:</strong>
32
+
Store table:
33
+
+---------+-------------+--------+
34
+
| bill_id | customer_id | amount |
35
+
+---------+-------------+--------+
36
+
| 6 | 1 | 549 |
37
+
| 8 | 1 | 834 |
38
+
| 4 | 2 | 394 |
39
+
| 11 | 3 | 657 |
40
+
| 13 | 3 | 257 |
41
+
+---------+-------------+--------+
42
+
<strong>Output:</strong>
43
+
+------------+
44
+
| rich_count |
45
+
+------------+
46
+
| 2 |
47
+
+------------+
48
+
<strong>Explanation:</strong>
49
+
Customer 1 has two bills with amounts strictly greater than 500.
50
+
Customer 2 does not have any bills with an amount strictly greater than 500.
51
+
Customer 3 has one bill with an amount strictly greater than 500.
0 commit comments