Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using the ICASE function
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01514002
Message ID:
01514006
Vues:
51
>There is supposedly a parentheses missing according to the compiler. All was well until I added an ICASE() function.
>
>
>	SELECT ;
>			d.GrpName, ;
>			d.GrpID, ;
>			d.Emp_ID, ;
>			d.BnftName, ;
>			SUM(d.bill_prem) AS Month_Billed, ;
>			SUM(d.cash_paid) AS Month_Collected, ;
>			ICASE(d.Bill_Mode="M", SUM((d.Bill_prem) * 12, ;
>				d.Bill_Mode="Q", SUM(d.Bill_Prem) * 4, ;
>				d.Bill_Mode="S", SUM(d.Bill_Prem) * 2, ;
>				d.Bill_Mode="A", SUM(d.Bill_Prem), ;
>				SUM(d.Bill_Prem) * 12) AS Annual_Prem, ;
>			l.Lives ;
>		FROM curDataDetail d;
>		JOIN tmpLives l ON d.GrpID = l.GrpID ;
>		WHERE BETWEEN(d.dBilling, ldFirstDateOfMonth, ldLastDateOfMonth) ;
>		GROUP BY GrpName, d.GrpID, d.Emp_ID, d.BnftName, l.Lives ;
>		INTO CURSOR ("tmp" + ALLTRIM(STR(lnMonth)))
>
Try instead:
SELECT ;
			d.GrpName, ;
			d.GrpID, ;
			d.Emp_ID, ;
			d.BnftName, ;
			SUM(d.bill_prem) AS Month_Billed, ;
			SUM(d.cash_paid) AS Month_Collected, ;
			SUM(ICASE(d.Bill_Mode="M", d.Bill_prem * 12, ;
				d.Bill_Mode="Q", d.Bill_Prem * 4, ;
				d.Bill_Mode="S", d.Bill_Prem * 2, ;
				d.Bill_Mode="A", d.Bill_Prem, ;
				d.Bill_Prem * 12)) AS Annual_Prem, ;
			l.Lives ;
		FROM curDataDetail d;
		JOIN tmpLives l ON d.GrpID = l.GrpID ;
		WHERE BETWEEN(d.dBilling, ldFirstDateOfMonth, ldLastDateOfMonth) ;
		GROUP BY GrpName, d.GrpID, d.Emp_ID, d.BnftName, l.Lives ;
		INTO CURSOR ("tmp" + ALLTRIM(STR(lnMonth)))
SUM must be outside the ICASE for this to work properly.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform