You first need to number the rows in ascending order to get a row number and then divide quantity/cons by this number, and then compute a running sum in reverse order from this.

Here is a query:

```
WITH numbering AS (
SELECT oid, OID2, SaleDateId, quantity, cons,
row_number() OVER (ORDER BY oid) as rowno
FROM main2
)
SELECT oid, OID2, SaleDateId,
cast (SUM(1E0*(cons/quantity) / rowno) OVER (ORDER BY rowno DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
AS decimal(10,2)) AS Cumulative
FROM numbering
ORDER BY oid
```