I am trying to create 3 options instead of just true or false options of an if statement. This is what I need:

If B3 is greater than A3 and less than C3, the D3 will have the value of Number B3 in it
If B3 is less than A3, then D3 will have the value of number A3 in it
If B3 is greater than C3, then D3 will have the value of number C3 in it

I am so close but I just don't know what I did wrong.

Here is what I have:

=IF(AND(B3>A3,A3<C3),B3,IF(AND(B3<A3,A3>C3),C3,A3))

Thanks for the help.