Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL cumulative sums
Message
 
 
To
26/06/2019 09:44:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01669299
Message ID:
01669301
Views:
50
It is simple in the SQL Server 2014 and up.

>Is there a way to have a cumulative field in a SQL expression?
>
>If I had three records:
>
CREATE CURSOR t1 (cDesc c(10), nValue i)
>INSERT INTO t1 VALUES("Record 1", 10)
>INSERT INTO t1 VALUES("Record 2", 15)
>INSERT INTO t1 VALUES("Record 3", 7)
>
>SELECT cDesc, nValue, CUMULATIVE(nValue) as nCumulative ;
>    FROM t1 ;
>    ORDER BY 1 ;
>    INTO CURSOR t2
>
>BROWSE LAST NOWAIT
>* Should produce a data set:
>*     Record 1, 10, 10
>*     Record 2, 15, 25
>*     Record 3,  7, 32
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform