an aggregated function MAX return Null

How to set the result of Aggregated Function Max to 0 if the retrieved max value is Null?

 in sql script i can use Coalesce

or How to Check the Tcriteriaresult is Null?
var
  c : TCriteriaResult;
begin
  c := FManager.Find<TVoucher>.Select(Linq['VoucherNo'].Max.As_('MaxVoucherNo')).UniqueValue;
end;

Thanks
Ahmed

What do you want to convert from null to 0? The final max value or each MaxVoucherNo value?

You have several options (depending on your answer):

1. Filter out MaxVoucherNo values which are Null using a Where filter
2. Use Sql projection and add a raw "Coalesce" function
3. Use Condition projection to test if a value is null and return 0 or MaxVoucherNo
4. Check if VarIsNull(c.Values[0]) and convert to 0.