title: derive data calculation
body: <p>I want use derived data to get the total salary calculated based on the appointment handled (20 pounds for each) and the basic salary is 1000 pound. Also, the salary should be ordered by the month and year. </p>
  
  <p>The appointment table have appointment date and time, Worker table have WorkerID and WorkerName and the salary have the salaryID, appointmenthandled and appointment cost (20 pounds).
  I want to calculate the total salary based on basic salary 1000 pound each month and other cost (appointmenthandled * 20) order by date. 
  I have problem with ordering by date. </p>
  
  <h1>Appointment table</h1>
  
  <pre><code>AppointmenID |AppointmentDate  | MechanicID
  :----- | -----:     | :----:
  AI1   | 2017-01-01  | MI1
  AI2   | 2017-01-15  | MI2
  AI3   | 2017-02-01  | MI1
  </code></pre>
  
  <h1>Salary table</h1>
  
  <pre><code>SalaryID | Salary  | AppointmentCost
  :----- | -----:     | :----:
  1      | 1000       | 20
  </code></pre>
  
  <h1>Appointment table</h1>
  
  <pre><code>AppointmenID |AppointmentDate  | MechanicID
  :----- | -----:     | :----:
  AI1   | 2017-01-01  | MI1
  AI2   | 2017-01-15  | MI2
  AI3   | 2017-02-01  | MI1
  AI4   | 2017-01-25  | MI2
  </code></pre>
  
  <h1>Mechanic table</h1>
  
  <pre><code>MechanicID |MechanicName| SalaryID
  :----- | -----:     | :----:
  MI1   | Rooney      | 1
  MI2   | Stephan     | 1
  MI3   | Ronaldo     | 1
  </code></pre>
  
  <h1>EXPECTED OUTPUT</h1>
  
  <h2>salary of January</h2>
  
  <pre><code>AppointmentDate  | MechanicID | MechanicName | Salary| AppointmentCost| Appointment Handled | Salary
  :----- |      -----: | :----:   | ----:| :----:|:--|:-----|
  2017-01-01  | MI1    | Rooney   | 1000   | 20    |1  | 1020
  2017-01-15  | MI2    | Stephan  | 1000   | 20    |2  | 1040
  </code></pre>
  
  <h2>salary of February</h2>
  
  <pre><code>AppointmentDate  | MechanicID | MechanicName | Salary| AppointmentCost| Appointment Handled | Salary
  :-----      | -----:     | :----:  |:----- | -----:| :----:  |:-----
  2017-01-01  | MI1  |      Rooney   | MI1   | 1000  | 20      |1      | 1020
  </code></pre>
  
  <p>Can anyone help me.</p>