Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
HAVING phrase
Message
De
11/06/2008 10:12:55
 
 
À
11/06/2008 10:02:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01323049
Message ID:
01323079
Vues:
13
Guess I gave up too quick.

That's a good solution.

Curiously, now that I see it, it's obvious.

And it also explains to me why the field name confusion, since the HAVING clause allows reference to fields in the source table (for calculations like this one ...)

Thanks


>>A simple question about use of the HAVING phrase. Here's a sample SELECT statement
>>
Select  Partno		;
>>	, Sum (RealCost)	As RealCost		;
>>	, Sum (PostedCost) 	As PostedCost	;
>>	, Sum (RealCost - PostedCost)	As Variance		;
>>	, Sum (1)		As Count		;
>>	, Sum (NItems)	As NItems		;
>>	;
>>	from c_Source	                                          ;								;
>>	group By 1	;	;
>>	into Cursor c_Browse Readwrite
>>I'd like to be able to reference the RealCost field in the result in the HAVING phrase ... HAVING RealCost # 0 ... but I get an error message because of the name conflict with the field RealCost in the source cursor.
>>
>>How can I refer to the RealCost field in the result cursor (in the HAVING phrase)?
>>
>>Yes, I know I could choose a different name in the result cursor ... I'm hoping I don't have to.
>_
>James,
>
>Try
>
>>
Select  Partno		;
>	, Sum (RealCost)	As RealCost		;
>	, Sum (PostedCost) 	As PostedCost	;
>	, Sum (RealCost - PostedCost)	As Variance		;
>	, Sum (1)		As Count		;
>	, Sum (NItems)	As NItems		;
>	;
>	from c_Source	                                          ;								;
>	group By 1	;	;
>	into Cursor c_Browse Readwrite ;
>         having sum(RealCost) <> 0
>
Jim Nelson
Newbury Park, CA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform