Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select SUM and calculate sum() different values
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00382827
Message ID:
00383002
Vues:
19
>Has anyone come across these commands that return different results with the same query condition
>
>CODE SECTION
>-----------------
>rdates(1) = a date defined by the user
>rdates(2) = calculated date based on a rule - which is always the lesser of the two dates
>
>* sum the values between these dates
>CALCULATE SUM(hrs_driving+hrs_onduty) TO Results(1) ;
> FOR logs.employee_code = THISFORM.EMPLOYEE_CODE1.Text1.VALUE ;
> AND BETWEEN(logs.txdate,rdates(2),rdates(1))
>
>* sum the values between these dates
>SELECT SUM(hrs_driving+hrs_onduty) AS 'results1' ;
> FROM logs!logs INTO CURSOR 'test1' ;
> WHERE logs.employee_code = THISFORM.EMPLOYEE_CODE1.Text1.VALUE ;
> AND BETWEEN(logs.txdate,rdates(2),rdates(1))
>-----------------
>The results are :
> Calculate sum() = 73.5
> SQL sum() = 63.00
>
>IF ANY ONE CAN SPOT THE PROBLEM PLEASE LET ME KNOW...

Calculate Sum works with updated data while SQL Select works with data directly from the disk. In SQL Select, its reference is not from your currently opened table, so whatever current changes you have couldn't be included in the resultset.

I also noticed that your SQL Select don't have a GROUP BY which is required to come up with supposedly the same result.
JESS S. BANAGA
Project Leader - SDD division
...shifting from VFP to C#.Net

CHARISMA simply means: "Be more concerned about making others feel good about themselves than you are in making them feel good about you."
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform