Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to factor my cursor?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01151893
Message ID:
01152214
Vues:
23
Yep

I've tested this and it all seems to be working tickidyboo!

Thanks again BB



>>I have a cursor with records as follows:
>>
>>Route  Class  SType  Family  PrevPassngers PrevMult PrevNumTrips CurrPassengers CurrMult  CurrNumTrips
>>0588          D      G                386      1.75       676.79
>>0588          D      G                                                     147      1.00        147.00
>>0588          D      G                                                     194      1.00        194.00
>>0588          D      G                                                     313      1.00        213.00
>>0011          C      B                 33      1.75        57.86
>>0011          C      B                                                       1      1.00          1.00
>>0016          C      E                675      1.75      1183.51
>>0016          C      E                                                       3      1.00          3.00
>>0016          C      E                                                      17      1.00         17.00
>>0016          C      E                                                      10      1.00         10.00
>>...
>>
>>and need to condense/combine them into 1 rec for each Route/ClassStype/Family combo, i.e.
>>
>>Route  Class  SType  Family  PrevPassngers PrevMult PrevNumTrips CurrPassengers CurrMult  CurrNumTrips
>>0588          D      G                386      1.75       676.79           554      1.00        554.00
>>0011          C      B                 33      1.75        57.86             1      1.00          1.00
>>0016          C      E                675      1.75      1183.51            30      1.00         30.00
>>
>>Is there a quick SQLish way of doing this without having to loop and append and accumulate and all that?
>>There could just as easily be many recs to the left (prev) side to one or few on the right (curr)
>>
>>'ppreciate it
>>
>>Terry
>
>
>
>
>SELECT Route, Class, SType, Family,;
>       SUM(PrevPassngers) AS PrevPassngers,;
>       SUM(PrevMult)      AS PrevMult,;
>       SUM(PrevNumTrips)  AS PrevNumTrips,;
>       SUM(CurrPassengers)AS CurrPassengers,;
>       MAX(CurrMult)      AS CurrMult,;
>       SUM(CurrNumTrips)  AS CurrNumTrips;
>FROM MyTable;
>GROUP BY Route, Class, SType, Family;
>INTO CURSOR crsTest
>BROSE NORMAL
>
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform