I am trying to decipher the following Formula, so that I can I put it into SQL, however it is kicking me right square in the nuts.

=IF(AND(W7+H7<=0,IF(E7-H7-S7>0,E7-H7-S7,0)<=0),0,IF(W7+H7<IF(E7-H7-S7>0,E7-H7-S7,0),IF(W7+H7<0,0,W7+H7),IF(E7-H7-S7>0,IF(W7>H7,E7-S7,H7+AF7),H7)))


I have tried splitting it up into the relevant portions for comparisons, but the and operator is throwing me off.

I had thought it would break apart into something like this:
=IF(AND
(W4+H4<=0,IF(E4-H4-S4>0,then E4-H4-S4, else 0)<=0),then 0, else

IF(W4+H4<IF(E4-H4-S4>0,then E4-H4-S4,else 0)

,IF(W4+H4<0,then 0,else W4+H4)
,IF(E4-H4-S4>0,
IF(W4>H4,then E4-S4,else H4+AF4),H4)
)
)

However that doesn't seem to be the case as the And clause wants everything to be "True/ False"

My end goal is to put this into SQL, so I am literally trying to work this up as a series of case statements.

Thank you for any light you can shed on this.