Running total of a Column

How to get running total of a column value

N1QL does not support the OLAP functions.

I believe this is now possible using window functions

e.g.

SELECT eg.item `1.item`,eg.unitcost `2.unitcost`,eg.qty `3.qty`,                                                                     
       ROUND(SUM(eg.unitcost*eg.qty) OVER (ORDER BY eg.item ROWS UNBOUNDED PRECEDING),2) `4.runningtotal`
FROM [{"item":"apple","unitcost":0.55,"qty":3},
      {"item":"orange","unitcost":0.62,"qty":10},
      {"item":"pear","unitcost":0.59,"qty":1}] eg;

Results:

...
    "results": [
    {
        "1.item": "apple",
        "2.unitcost": 0.55,
        "3.qty": 3,
        "4.runningtotal": 1.65
    },
    {
        "1.item": "orange",
        "2.unitcost": 0.62,
        "3.qty": 10,
        "4.runningtotal": 7.85
    },
    {
        "1.item": "pear",
        "2.unitcost": 0.59,
        "3.qty": 1,
        "4.runningtotal": 8.44
    }
    ],
...