How to get same column values to make multiple columns? I don't know if my question is valid or not but I'm working on an attendance system, and I want to get some output for my project.

I have an attendance table that holds three columns: emp_id, atten_type and date. The atten_type column can contain one of three values; that is 'present', 'absent' and 'leave'.

Now, I want the output like this:
So grouping by emp_id, month and suming the count based on atten_type?

SELECT emp_id,
    SUM(IF(atten_type='present',1,0) as 'atten_type as present',
    SUM(IF(atten_type='leave',1,0) as 'atten_type as leave',
    SUM(IF(atten_type='absent',1,0) as 'atten_type as absent',
    MONTH(`date`) as 'month'
FROM
    attendance
GROUP BY emp_id, `month`