SELECT CONCAT(e.c_firstName,' ',e.c_Lastname) AS NAME ,
sum(CASE WHEN uc.c_name='ELECTRIC CHARGES' then uc.c_amount ELSE NULL END) AS Electric,
sum(CASE WHEN uc.c_name='GAS CHARGES' then uc.c_amount ELSE NULL END) AS GAS,
sum(CASE WHEN uc.c_name='FURNITURE CHARGES' then uc.c_amount ELSE NULL END) AS Furniture,
sum(CASE WHEN uc.c_name='WATER CHARGES' then uc.c_amount ELSE NULL END) AS WATER,
sum(CASE WHEN uc.c_name='TV LICENSE FEE' then uc.c_amount ELSE NULL END) AS TV_LICENSE_FEE
FROM app_fd_pr_uage_bill ub JOIN app_fd_pr_uagecateg_bil uc ON ub.id=uc.c_FrKeyUbill
JOIN app_fd_hrm_employee e
ON ub.c_employeeName=e.id
GROUP BY Name
1:Uage bill is a table where i am entering all bills of employee.
2:uageCategory bill is a table where i created a configuration for entering names of bills.
3:hrm_employee is a table where all employee of a company has been inserted.
this query is a hard coded query but i want a dynamic query where any row will be added in uage cateogry bill it will be automatically converted into a column using this query.