I'm confused with the below query, I expect the result should be 5 but it returns an empty sequence.
let $num := 5
let $num1 := ()
let $add := $num + $num1
return $add
I'm confused with the below query, I expect the result should be 5 but it returns an empty sequence.
let $num := 5
let $num1 := ()
let $add := $num + $num1
return $add

I don't know how close Marklogic XQuery is to the W3C XQuery standard but in that standard the rules for arithmetic expressions https://www.w3.org/TR/2010/REC-xquery-20101214/#id-arithmetic clearly say
So the empty sequence is the defined result as one operand is the empty sequence.
Perhaps the
sum()function,let $add := sum(($num, $num1)), is more what you are looking for.