>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