I would like some guidance on how to write the SQL for the following?
Lets say I have the following table:
Employee
EmpNo | EmpName | EmpCommRate
1 | John | 0.020
2 | Lewis | 0.040
3 | Bobby | 0.030
4 | Pete | 0.050
Orders
OrdNo | EmpNo
101 | 1
102 | 1
103 | 4
104 | 2
105 | 3
106 | 3
107 | 1
For each employee with a commission less than 0.040, compute the number of orders taken. The result should include the employee number, employee name, employee commission rate, and the total number of orders taken by that employee. Assume each distinct OrdNo in the Orders counts as one distinct order. Each employee should be displayed only once; for example, if employee Mickey took five orders, there should be one line displaying his name, not five.
Output should be:
EmoNo | EmpName | EmpCommRate | Total Orders
1 | John | 0.020 | 3
3 | Bobby | 0.030 | 2
What would be the best SQL command to output the above?