0
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.

6
  • You need in stored procedure with dynamic SQL. Commented Sep 16, 2021 at 8:00
  • can you ellaborate it Commented Sep 17, 2021 at 9:18
  • Do this like in stackoverflow.com/a/69204421/10138734 Commented Sep 17, 2021 at 9:21
  • I have seen that type of solution before, but Group_concat function is not working in HeidSQL Server, and i have limitation not to use other servers yet to attempt this query is HeidiSQL server using mysQL. Commented Sep 17, 2021 at 12:49
  • Group_concat function is not working in HeidSQL Server HeidiSQL Server - what is it? I know HeidiSQL, and it is a client which simply sends SQL text to the server, hence it cannot "not working". Commented Sep 17, 2021 at 18:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.