Вы можете попробовать использовать условное агрегирование
select
name,
max(case when leave_type='Annual' then "total lday" end) as Annual,
max(case when leave_type='Casual' then "total lday" end) as Casual,
max(case when leave_type='Earned' then "total lday" end) as Earned,
balance leave,balance
from tablename
group by name,balance leave,balance