Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL cumulative sums
Message
 
 
À
26/06/2019 09:44:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01669299
Message ID:
01669301
Vues:
51
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform