Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL columns
Message
De
21/10/1997 19:23:16
 
 
À
21/10/1997 16:26:15
Matt Mc Donnell
Mc Donnell Software Consulting
Boston, Massachusetts, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00055848
Message ID:
00055901
Vues:
31
>>I am trying to build a view that totals an amount filed, I wish to have one column total be a YTD total and another column for just a particular day. I have tried using a join but that gives two rows for the result, I need one row with both totals.
>>
>>TIA
>>
>>Ian
>
>I don't think you can do that with a view. Calculated fields based on other records?
>
>But with a cursor you can do it:
>here's one way:
>
>
>nMyYTDTotal = 0
>
>SELECT dDate, SUM(amount) AS nTodaysTotal, MyYTD(amount) AS nYTD FROM MyTable WHERE dDate>={01/01/97} ORDER BY dDate, GROUP BY dDate INTO CURSOR _MyTotals
>
>FUNC MyYTD(nAmt)
>  nMyYTDTotal = nMyYTDTotal + nAmt
>RETURN nMyYTDTotal
>
>
>
>HTH

Nope! MyYTD will add twice the first record.

Vlad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform