# Excel formulas to SQL

## Question

Snora on Wed, 15 May 2019 07:52:21

i couldnt solve this codes. If some one could help that would be great.

"E1335" =IF(D135=0,0,IF(AND(AU135/D135>=0.8,AU135/D135<1),1,ROUNDDOWN(AU135/D135,0)))

I did this:

CASE WHEN [D135] = 0 THEN 0

WHEN [AU135] / [D135] >= 0.8 AND [AU135] / [D135] < 1 THEN 1

ELSE Floor ([AU135] / [D135])

END AS E135,

here Comes the Problem in SQL since in this part it links back to (E135) the 1. if calculation and just fail.

"F135" =IF(C135=0,0,IF(E135=1,0,ROUNDDOWN((AU135-E135*D135)/C135,0)))

CASE WHEN [C135] = 0 OR E135 1 THEN 0

ELSE Floor ([AU135] - [E135] * [D135] / [C135]) END AS [F135]

"G135" =IF(B135=0,0,IF(E135=1,0,ROUNDDOWN((AU135-E135*D135-F135*C135)/B135,0)))

## Replies

EitanBlumin on Wed, 22 May 2019 11:37:34

It looks like you're missing an equality operator in this line:

CASE WHEN [C135] = 0 OR E135 1 THEN 0

It should be:

CASE WHEN [C135] = 0 OR E135 = 1 THEN 0

Latest posts in the category

windows metro apps games

windows phone development