Skip to Content
Oct 30, 2019 at 04:02 PM

Pivot columns in query SAP B1


I create query like below. I get a table including 4 columns: Item code, Qty, Amount, & Month.

Now I want to pivot this table to convert to 3 columns: Item code, Month_Qty, & Month_Amount.

Please advice. Thanks!

<code>SELECT T1.[ItemCode], T1.[Dscription], T1.[Quantity] as Qty, T1. 
[Quantity]*T1.[Price] as Amount, Month(T0.[DocDate] as 
'Month' FROM OIGE T0  INNER JOIN IGE1 T1 ON T0.[DocEntry] = T1. 
[DocEntry] WHERE T0.[DocDate] >=[%0] and  T0.[DocDate] <=[%1] and T0. 
[Comments] NOT Like '%%Automatically%%'