Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
if(isnull(ScannedSales), if(isnull(EnteredSales), 0, EnteredSales), if(isnull(EnteredSales), ScannedSales, if(EnteredSales > ScannedSales, EnteredSales, ScannedSales))) as RealSales,
Can someone please break above statement and explain how it works and what it does. thanks
Maybe it will help you to see the code with indents:
if(isnull(ScannedSales),
if(isnull(EnteredSales),
0,
EnteredSales),
if(isnull(EnteredSales),
ScannedSales,
if(EnteredSales > ScannedSales,
EnteredSales,
ScannedSales
)
)
) as RealSales,
if(isnull(ScannedSales), //Your First IF Start
if(isnull(EnteredSales), 0, EnteredSales), // First IF TRUE
if(isnull(EnteredSales), // First IF False (2nd IF Start)
ScannedSales, // 2nd IF TRUE
if(EnteredSales > ScannedSales, EnteredSales, ScannedSales))) // 2nd IF False with 3rd IF TRUE and FALSE)
This will
if(isnull(ScannedSales), //If this expression true then below line checks expression for null()
if(isnull(EnteredSales), 0, EnteredSales), //For True if condition part
if(isnull(EnteredSales), ScannedSales, //For False if condition part
if(EnteredSales > ScannedSales, EnteredSales, ScannedSales) //Second nested if condition with true and false fields
) //Second If end here
) //First If end here
as RealSales,
Regards,
Anand