0

Table

I have a table like above. I need out like below Using Mysql query.

Output

Bipin
  • 334
  • 6
  • 21
  • 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
  • 1
    This 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 Answers1

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