I am new with search records between two dates and show records sorted by months (from January through December).
I have table like this.
Employee | Salary | Date from | Date To
John A. | 15000 | 2013-05-26 | 2013-06-10
Mark | 15000 | 2013-05-26 | 2013-06-10
John A. | 15000 | 2013-06-11 | 2013-06-25
Mark | 20000 | 2013-06-11 | 2013-06-25
I want the report to be shown something like this.
Employee | 26 May - June 10 | 11 June - 25 June | So on..
John A. | 15000 | 15000
Mark | 15000 | 20000
Please see my codes. this will only search the records between two dates
SELECT *
FROM payroll
WHERE datefrom >= '2013-01-01'
AND dateto < '2013-12-31'
Please give me an idea how to resolve the situation.