Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Having Trouble with Group By in VFP 9
Message
 
À
16/03/2006 14:37:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01105032
Message ID:
01105034
Vues:
22
>I am working with an application written in VFP 6 and keep running into problems with sql statements containing a Group By clause. I haven't found a common denominator. Any ideas?
>
>Here is an example cut from the code:
>
>
>SELECT ;
>     receipt.rec_date,receipt.receipt_no, paidinv.inv_no, ;
>     receipt.type, receipt.card_no, receipt.exp_date, ;
>     receipt.amount, receipt.country, receipt.exch_rate ;
>	WHERE receipt.type $ "AMV" .and. receipt.rec_date = date() ;
>        FROM receipt ;
>	INNER JOIN paidinv ON receipt.receipt_no = paidinv.receipt_no ;
>        Group By Receipt.receipt_no ; 	
>        ORDER BY type ;
>	INTO CURSOR dispcred
>
>
>Thanks, Jeffrey

Check SET ENGINEBEHAVIOUR command in HELP. GROUP BY must include all non agregate fields used in your select.
SELECT ;
     receipt.rec_date,receipt.receipt_no, paidinv.inv_no, ;
     receipt.type, receipt.card_no, receipt.exp_date, ;
     receipt.amount, receipt.country, receipt.exch_rate ;
	WHERE receipt.type $ "AMV" .and. receipt.rec_date = date() ;
        FROM receipt ;
	INNER JOIN paidinv ON receipt.receipt_no = paidinv.receipt_no ;
        Group By Receipt.receipt_no, receipt.rec_date,paidinv.inv_no, ;
                 receipt.type, receipt.card_no, receipt.exp_date, ;
                 receipt.amount, receipt.country, receipt.exch_rate ;
        ORDER BY type ;
	INTO CURSOR dispcred
You you should use MAX() (or MIN()) on every field you didn't care.
But for easy change just SET ENGINEBEHAVIOUR 70 in your main program. Than change all selects to match the new criteria and after that remove that line.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform