0

i need to make the data in the column to be column head

this is the current result from my query .. :

select employee_id,reimbursement_type,SUM(amount) as [total amount],reimbursement_status from md_reimbursement group by employee_id,reimbursement_type,reimbursement_status

enter image description here

and i want it to be like this :

enter image description here

*just ignore the Status field

so the data reimbursement_type to become a column head and it SUM each amount.

i already tried using pivot but didnt get what i expected.

thx

Borom1r
  • 155
  • 1
  • 7
  • 18

1 Answers1

2

Prepared a sample according to your requirement. As you have mentioned to ignore Status, I am not considering it into the query.

select * from 
(
select employee_id,reimbursement_type,amount from md_reimbursement
)src
pivot
(
sum(amount) for reimbursement_type in ([Biaya Dinas],[Other],[Transport],[Uang Makan])
)pvt
maulik kansara
  • 1,087
  • 6
  • 21