SUM() always return null on existing values

I’m having an issue with the SUM() function… I can query a document list and see the list of purchase totals (ie. total purchase amount of each purchase). When I try to get the sum of the purchase totals I simply receive a null.

Here is a rough example subset of document:
{
id: 12
PurchaseHeaders
{
total: 19.95
}
}

{
id: 13
PurchaseHeaders
{
total: 10.00
}
}

when I query:
"select PurchaseHeaders.total from bucket" I correctly receive:
total: 19.95
total: 10.00

when I query:
"select sum(PurchaseHeaders.total) as total from bucket" I receive:
total: null

In fact it seems that any math functions return null. Here’s another example:
SELECT CartTotals.total, CartTotals.total + 10 from bucket
{
“$1”: null,
“total”: “19.95”
},
{
“$1”: null,
“total”: “10.00”
}

I’m using server 4.6

The following work fine with 4.6.3-4136

INSERT INTO default VALUES("12", { "id": 12, "PurchaseHeaders": { "total": 19.95 } });
INSERT INTO default VALUES("13", { "id": 13, "PurchaseHeaders": { "total": 10.00 } });
SELECT PurchaseHeaders.total FROM default;
SELECT SUM(PurchaseHeaders.total) FROM default;
SELECT PurchaseHeaders.total, PurchaseHeaders.total+ 10 FROM default;

Arithmetic operations can be done only on numeric fields. If the fields are not numeric it will be ignored and final result may be NULL. numbers are stored in string use TONUMBER() to convert.

Thank you!! That worked - such a simple reason for all my troubles… :smiley: