I am currently doing a task where i need to calculate the sum of total amount of product each employee has. Then, I need to set a fix amount(5000) and display those employees who have total amount less than the fix amount(5000). Can anyone provide examples of queries for this particular problem?
Table T2 will return list of employees less than 5000,then join it with your employee master table T2. Change the table names as needed.
SELECT * FROM EMPLOYEE T1 JOIN
(SELECT EmployeeID,SUM(AMOUNT) AMOUNT FROM PRODUCT
GROUP BY EmployeeID
HAVING SUM(AMOUNT)<5000) T2 ON T1.EmployeeID=T2.EmployeeID