Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AS Clause
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00409807
Message ID:
00409957
Vues:
23
>Hi George,
>>>>>When i execute the folowing SQL query, i get the error colomn "WTG"not found.
>>>>>
>>>>>SELECT detail.avr_ari,;
>>>>> iif(Detail.avr_wtg=.t.,'J','N') as WTG;
>>>>>FROM general!detail;
>>>>>WHERE WTG='J'
>>>>>
>>>>>Is this an impossible kind of query, to include an expressionalias in the WHERE Clause ?
>>>>>

You can't reference the results of the SELECT during the WHERE, because the resulting element doesn't exist. You have two basic choices:

WHERE detail.avr_wgt

oe defer the decision until the result set is formed, and place it in the HAVING clause:

HAVING WTG = 'J'

>>>>>Any idea's how to solve this ?
>>>>>
>>>>
>>>>Bjorn,
>>>>
>>>>The WHERE clause of SELECT si applied to the source tables, there is no fild named WTG in the source fields. You can change it to;
>>>>
>>>>WHERE Detail.avr_wtg = "J"
>>>>
>>>
>>>This will cause a data-type mismatch. If he's testing against the result of the iif(), he's got to use the HAVING clause.
>>
>>Naw, you don't need a HAVING or a comparison operator, simply
SELECT detail.avr_ari, "J" AS WTG;
>>FROM general!detail;
>>WHERE Detail.avr_wtg
will do the trick. Using Detail.avr_wtg = .T. slows things down.
>
>I agree you don't HAVE to use HAVING to solve this problem. BUT, if you need to test against the result of the iif() (or any function for that matter) you need to use the HAVING clause. That was my intended point.
>
>BTW, Is it REALLY faster to skip the '= .T.'? I've never tested that. I tend to be explicit so that my SQL converter can parse more easily for SPT to SQL Server or (soon) Oracle.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform