Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL-WHERE error en campo calculado
Message
 
 
To
26/01/2007 10:50:55
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01189655
Message ID:
01189660
Views:
7
>Hola,
>Tengo el siguiente inconveniente:
>Hago el siguiente sql si probleas
>
>select a.codcli as cliente, a.codnom as nombre, ;
>porc_cal(a.impo1,b.impo1) as porcentje from tabla1 as a. tabla2 as b ;
>where (a.codcli = b.codcli) into table salida
>funciona ok...
>aparecen los tres campos
>cliente,nombre,porcentaje
>ahora bien si yo quiero hacer en el mismo sql que solamente me liste los de porcentajes > 10 me da el siguiente error "columna porcentaje no existe"
>y lo hago así.
>select a.codcli as cliente, a.codnom as nombre, ;
>porc_cal(a.impo1,b.impo1) as porcentje from tabla1 as a. tabla2 as b ;
>where ;
>(a.codcli = b.codcli) and (porcentje > 10) ;
>into table salida
>la unica diferencia con el sql anterior es:
>and (porcentje > 10)
>no encontre nada en el manual que me aclarara sobre el tema.
>Desde ya les agradezco por vuestro tiempo.
>Saludos

Sorry for the English, but you can not use calculated (new) columns in WHERE expression. You can use them in HAVING clause, but I never used HAVING without GROUP BY (AFAIK it's possible).

Perhaps you would need to do it in two select statements instead.

BTW, don't use single letter aliases for tables. Use at least two letters.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform