Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL error
Message
De
21/04/2015 21:03:38
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01618877
Message ID:
01618930
Vues:
38
redeem.dredeemdat is never null, although it can be empty.

>Add redeem.Dredeemdat IS NOT NULL condition to that select.
>
>>I should have added that the phrase is returning wrong values only when there is a group by and no order by.
>>
>>>But they are not. It seems I had it backwards. It works as long as there is an ORDER BY. With no ORDER BY, the numbers are wild.
>>>
>>>I ran the query with no grouping to see if I could tell what was happening. What is happening is that without the ORDER BY, this phrase:
>>>
>>>
>>>				WHERE b.control_no in ;
>>>					(SELECT towfky FROM redeem WHERE redeem.dredeemdat>= {01/01/2014} AND redeem.dredeemdat<= {12/31/2014}) ;
>>>
>>>
>>>
>>>is responding true and including records where redeem.dredeemdat is empty!
>>>
>>>>I agree with Boris. If the only change in these two statements is the added ORDER BY, then it should not matter and results should be the same.
>>>>
>>>>>It's one of those morning after an all-nighter (which I am getting too old for) and I would appreciate it if somebody would point out my error, probably obvious:
>>>>>
>>>>>Works:
>>>>>
>>>>>
>>>>>       * REPLACED ACTUAL TABLE NAMES FOR THIS EXAMPLE:
>>>>>	SELECT a.ccompany, a.custcode, COUNT(b.req_date) as nTotal,  ;
>>>>>					SUM(b.nstorage) as nStorage, SUM(b.tow_chrg) as nTows ;
>>>>>				FROM a;
>>>>>				JOIN b ON b.custcode = a.custcode;
>>>>>				WHERE b.control_no in ;
>>>>>					(SELECT towfky FROM redeem WHERE redeem.dredeemdat>= {01/01/2014} AND redeem.dredeemdat<= {12/31/2014}) ;
>>>>>				GROUP BY 1,2 ;
>>>>>				into cursor temp1 readwrite 
>>>>>
>>>>>
>>>>>Now add the ORDER and the totals go haywire
>>>>>
>>>>>
>>>>>       * REPLACED ACTUAL TABLE NAMES FOR THIS EXAMPLE:
>>>>>	SELECT a.ccompany, a.custcode, COUNT(b.req_date) as nTotal,  ;
>>>>>					SUM(b.nstorage) as nStorage, SUM(b.tow_chrg) as nTows ;
>>>>>				FROM a;
>>>>>				JOIN b ON b.custcode = a.custcode;
>>>>>				WHERE b.control_no in ;
>>>>>					(SELECT towfky FROM redeem WHERE redeem.dredeemdat>= {01/01/2014} AND redeem.dredeemdat<= {12/31/2014}) ;
>>>>>				GROUP BY 1,2 ;
>>>>>                                ORDER BY 1,2 ;
>>>>>				into cursor temp1 readwrite 
>>>>>
>>>>>
>>>>>TIA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform