Below is my query
SELECT salary.id,
employee.emp_id,
employee.emp_name,
department.dept_name,
designation.desig_name,
salary.basic,
salary.house_rent + salary.conveyance + salary.medical + salary.dearness + salary.others_allowances AS allowances,
salary.income_tax + salary.pro_tax + salary.emp_state_insu + salary.others_deductions AS deductions,
Sum(attendance.attendance = 'Absent') * salary.absence_fine AS fine,
Monthname(attendance.date) AS month,
salary.month AS monYear
FROM employee
INNER JOIN attendance ON employee.emp_id = attendance.emp_id
INNER JOIN department ON employee.dept_id = department.dept_id
INNER JOIN designation ON employee.desig_id = designation.desig_id
INNER JOIN salary ON designation.desig_id = salary.desig_id
GROUP BY salary.id,
employee.emp_id,
Monthname(attendance.date)
My output is:
Please help me to figure out this problem
You need a column to relate attendance with salary lets say that you have a column called month_id on each table, then u can add a condition in the last inner join. something like this:
INNER JOIN salary ON designation.desig_id = salary.desig_id and attendace.monthId = salary.month_id