w3resource
SQL exercises

SQL Exercises: Highest purchase amount on a particular date for individual salesman

SQL Aggregate Functions: Exercise-11 with Solution

Write a SQL statement to find the highest purchase amount on a date '2012-08-17' for each salesman with their ID.

Sample table: orders


Sample Solution :

SELECT salesman_id,MAX(purch_amt) 
FROM orders 
WHERE ord_date = '2012-08-17' 
GROUP BY salesman_id;

Output of the Query:

salesman_id	max
5003		110.50
5007		75.29

Explanation:

Syntax of Highest purchase amount on a particular date for individual salesman

Pictorial presentation :

Highest purchase amount on a particular date for individual salesman

Query Visualization:

Duration:

Query visualization of Highest purchase amount on a particular date for individual salesman - Duration

Rows:

Query visualization of Highest purchase amount on a particular date for individual salesman - Rows

Cost:

Query visualization of Highest purchase amount on a particular date for individual salesman - Cost

 

Practice Online


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a SQL statement to find the highest purchase amount ordered by the each customer on a particular date with their ID, order date and highest purchase amount.
Next: Write a SQL statement to find the highest purchase amount with their ID and order date, for only those customers who have highest purchase amount in a day is more than 2000.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming