Feroz Khan

Feroz Khan

  • 1.4k
  • 300
  • 93.4k

Column data want to convert in columns

Aug 16 2023 9:49 PM

Dear all, 

I want to retrive column data into columns like below sql query and result snap the issue is result not coming date wise each value showing seprate seprate date multiple times.

i want one date value in same row, not in seprate seprate row.

Please need your support.

 select Branch, Account, PDGNumber, trandate, grandvalue grand,
   cast(feesvalue as decimal(5,2)) fees, 
  max(case when Channel = 'Visa' then Credit_amount end) Visa,
  max(case when Channel = 'Mada' then Credit_amount end) Mada,
  max(case when Channel = 'Master' then Credit_amount end) Masters,
  max(case when Channel = 'GCC' then Credit_amount end) GCC,
    max(case when Channel = 'Amex' then Credit_amount end) Amex
  from Bank_Statement where channel in ('Visa','Mada','Master','GCC','Amex')
  group by branch, account, trandate,  feesvalue, PDGNumber, GrandValue

 

Result


Answers (6)