下面是我的问题
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)
我的输出是:
请帮我弄清楚这个问题
发布于 2018-12-18 02:59:46
您需要一个列来将出勤与工资联系起来,假设每个表上都有一个名为month_id的列,那么您可以在最后一个内连接中添加一个条件。如下所示:
INNER JOIN salary ON designation.desig_id = salary.desig_id and attendace.monthId = salary.month_id
https://stackoverflow.com/questions/53821251
复制相似问题