cancel
Showing results for 
Search instead for 
Did you mean: 

Excel formula to SQL formula for query

jeroenw
Participant
0 Kudos

Hi,

I have an Excel formula that I want to convert to an SQL formula so I can use it in a query.

The Excel formula is:

=D2*CEILING((B2-C2)/D2;1)

I thought I could use RoundUp, but that funcation is not available in SAP.

The formula in SAP looks like this:

t0.purpackun*RoundUp((T1.[Maxstock]-((t1.onhand-t1.iscommited)+ t1.onorder))/t0.purpackun,1) as 'Order quantity',

View Entire Topic
LoHa
Active Contributor
0 Kudos

Hi

you can try this

SELECT 
 [OITM].[PurPackUn]
,[OITW].[Maxstock]
,[OITW].[OnHand]
,[OITW].[IsCommited]
,[OITW].[OnOrder]
,[OITM].[PurPackUn]*CEILING(([OITW].[Maxstock]-[OITW].[OnHand]-[OITW].[IsCommited]+[OITW].[OnOrder])/[OITM].[PurPackUn]) AS [OrderQty]
FROM 
OITM
INNER JOIN OITW ON OITW.ItemCode= OITM.ItemCode AND OITW.WhsCode = 'xx'
WHERE
OITM.ItemCode = 'xx'

regards Lothar