Skip to content

Commit fd44327

Browse files
authored
Create SQL Exercises: Find the highest purchase amount of the customers in a particular date
1 parent 405cead commit fd44327

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
https://www.w3resource.com/sql-exercises/sql-aggregate-function-exercise-12.php
2+
3+
SQL Aggregate Functions: Exercise-12 with Solution
4+
From the following table, write a SQL query to find highest order (purchase) amount by each customer in a particular order date. Filter the result by highest order (purchase) amount above 2000.00. Return customer id, order date and maximum purchase amount.
5+
6+
Sample table: orders
7+
ord_no purch_amt ord_date customer_id salesman_id
8+
---------- ---------- ---------- ----------- -----------
9+
70001 150.5 2012-10-05 3005 5002
10+
70009 270.65 2012-09-10 3001 5005
11+
70002 65.26 2012-10-05 3002 5001
12+
70004 110.5 2012-08-17 3009 5003
13+
70007 948.5 2012-09-10 3005 5002
14+
70005 2400.6 2012-07-27 3007 5001
15+
70008 5760 2012-09-10 3002 5001
16+
70010 1983.43 2012-10-10 3004 5006
17+
70003 2480.4 2012-10-10 3009 5003
18+
70012 250.45 2012-06-27 3008 5002
19+
70011 75.29 2012-08-17 3003 5007
20+
70013 3045.6 2012-04-25 3002 5001
21+
22+
23+
select customer_id, ord_date,max(purch_amt)
24+
from orders
25+
group by customer_id,ord_date
26+
having max(purch_amt) > 20000
27+
;

0 commit comments

Comments
 (0)