Complex left join sql
I am trying to make a report for salaries of a company and I want to show
all the employees of the company by using some query like this:
select tab1.name, tab1.job,tab1.salary, tab2.discount-days,
(tab1.salary-((tab1.salary/30)*tab2.discount-days) as 'total' from tab1
left join tab2 on tab1.PK = tab2.FK and tab2.date between '01/09/2014' and
'30/09/2014' ;
Here it shows all the employees and that have taken discounts but the
period condition does not work as it show all the discounts that have been
given to the employee
Please need help to make the query to work well with the period condition
No comments:
Post a Comment