You can use
select Class, Attendance, count(*) as No from <table> group by Class, Attendance</table>
Then use this as the inner query on a pivot to transform the data to how you need.
select Class, P+A+L as Students, P as Present, A as Absent, L as Leaves
from (select Class, Attendance, count(*) as No
from <table>
group by Class, Attendance
) src Pivot ( sum(No) for Attendance in ( [P], [A], [L] )) pvt
</table>