Write SELECT statement that returns the "Representative ID" and their highest sales total of that sales representative, grouped by the " Representative ID" .
Representative ID : rep_id column of rep_totals table
"Highest sales of Representative " : maximum sales_total of that representative.
Return only the rep_id whose highest sales_total is greater than 900000
Expected Output:
Representative ID Highest sales of representative
1 1274856.38
2 978465.99
3 1132744.56
Select rep_id AS “Representative ID Highest sales of representative” from rep_totals GROUP BY rep_id HAVING SUM(sales_total)>5000;
The above-mentioned command has to be written to fetch the expected output as given in the question.
GROUP BY CLAUSE:
HAVING CLAUSE:
In this question firstly rep_id has to be mentioned as in the name of Representative ID Highest sales of representative.
Representative id has to be fetched from our present total sales table named as rep_totals.
Get Answers For Free
Most questions answered within 1 hours.