i want to sum up values of a row in a single column using MySQL. I have tried all the below codes but nothing seems to work, i need help please
What I have tried:
C#
SELECT employee.dept,employee.loc, employee.work,
COUNT(IF(employee_info.emp_date = '2021-11-01', employee_info.emp_date, NULL)) AS a,
COUNT(IF(employee_info.emp_date = '2021-11-02', employee_info.emp_date, NULL)) AS b,
COUNT(IF(employee_info.emp_date = '2021-11-02', employee_info.emp_date, NULL)) AS c, SUM("a"+"b"+"c") AS total FROM employee_info INNER JOIN employee ON employee_info.employee_number = employee.employee_number GROUP BY employee.dept WITH ROLLUP
SELECT employee.dept,employee.loc, employee.work,
COUNT(IF(employee_info.emp_date = '2021-11-01', employee_info.emp_date, NULL)) AS a,
COUNT(IF(employee_info.emp_date = '2021-11-02', employee_info.emp_date, NULL)) AS b,
COUNT(IF(employee_info.emp_date = '2021-11-02', employee_info.emp_date, NULL)) AS c, SUM('a'+'b'+'c') AS total FROM employee_info INNER JOIN employee ON employee_info.employee_number = employee.employee_number GROUP BY employee.dept WITH ROLLUP
SELECT employee.dept,employee.loc, employee.work,
COUNT(IF(employee_info.emp_date = '2021-11-01', employee_info.emp_date, NULL)) AS a,
COUNT(IF(employee_info.emp_date = '2021-11-02', employee_info.emp_date, NULL)) AS b,
COUNT(IF(employee_info.emp_date = '2021-11-02', employee_info.emp_date, NULL)) AS c, 'a'+'b'+'c' AS total FROM employee_info INNER JOIN employee ON employee_info.employee_number = employee.employee_number GROUP BY employee.dept WITH ROLLUP
Nitin SontakkeRank #264 · 9.6K reputationPosted Jan 16, 2022, 12:05 AM EST
Abdu AbdulRank #5,389 · 301 reputationPosted Jan 16, 2022, 8:55 AM EST
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Jan 16, 2022, 10:55 AM EST