I have two tables per below:
1. DatesMaster
+----------+---------------+
| m_date | capacity |
+----------+---------------+
| 1/2/2016 | 10 |
| 2/2/2016 | 10 |
| 3/2/2016 | 10 |
+----------+---------------+
2. Schedule
+----------+-------+
| sch_date | qty |
+----------+-------+
| 1/2/2016 | 2 |
| 1/2/2016 | 2 |
| 1/2/2016 | 2 |
| 2/2/2016 | 5 |
| 2/2/2016 | 5 |
| 3/2/2016 | 5 |
| 3/2/2016 | 1 |
+----------+-------+
How do I get the result of capacity - qty
using left outer join whereby I can display all dates from DatesMaster
with Availability
as the difference between capacity
and sum of qty
of same dates?