I have a table like above. I need out like below Using Mysql
query.
Asked
Active
Viewed 34 times
0
-
I tried `SELECT emp_name,count(attendance) FROM `test`where attendance='present' GROUP by emp_name`. but this is not i want. – Bipin Mar 05 '18 at 07:36
-
1This question has been answered numerous times here is SO. Please spend some time researching the site for relevant answers before posting a question. – Giorgos Betsos Mar 05 '18 at 07:39
1 Answers
1
You can calculate the result by using conditional aggregate,
SELECT EMP_NAME,
SUM(attendance = 'Present') AS `No of Present`,
SUM(attendance = 'Absent') AS `No of Absent`
FROM tableName
GROUP BY EMP_NAME

John Woo
- 258,903
- 69
- 498
- 492