Thread: Sugerencia de opcion

Sugerencia de opcion

From
"Informatica-Cooperativa Cnel. Oviedo"
Date:
Buenos Dias todos, <br /><br />                             Soy un usuario de postgres de Paraguay, consulto sobre la
posibilidadde inclucion en la futura version la siguiente sentencia(Uso de alias en la condicion HAVING ):<br /><br
/><br/>     SELECT id, sum(salario) as SumaSalario<br />     FROM salarios<br />     GROUP BY id<br />     HAVING
<b>SumaSalario</b>>500;<br/><br /><br />      Saludos,<br /><br /><br /><br /> Edgar Villalba. (edgvill)<br />
Paraguay<br/>    <br /><br /><br /> 

Re: [HACKERS] Sugerencia de opcion

From
Robert Haas
Date:
2009/1/22 Informatica-Cooperativa Cnel. Oviedo <informatica@coopovie.com.py>:
> Buenos Dias todos,
>
>                             Soy un usuario de postgres de Paraguay, consulto
> sobre la posibilidad de inclucion en la futura version la siguiente
> sentencia(Uso de alias en la condicion HAVING ):
>
>
>     SELECT id, sum(salario) as SumaSalario
>     FROM salarios
>     GROUP BY id
>     HAVING SumaSalario>500;

I've wished for that syntax once or twice myself, but I'm assuming
there's a reason we haven't implemented it?  Part of the problem is
it's inheritantly ambiguous if salarios happens to contain a column
called sumasalario, which is a problem that seems to arise for me
fairly regularly in practice.  Still, it would be nice for WHERE/GROUP
BY/HAVING clauses to have an explicit way to reference "the target
list column called foo".

...Robert

Re: [HACKERS] Sugerencia de opcion

From
Tom Lane
Date:
Robert Haas <robertmhaas@gmail.com> writes:
> 2009/1/22 Informatica-Cooperativa Cnel. Oviedo <informatica@coopovie.com.py>:
>> ��� SELECT id, sum(salario) as SumaSalario
>> ��� FROM salarios
>> ��� GROUP BY id
>> ��� HAVING SumaSalario>500;

> I've wished for that syntax once or twice myself, but I'm assuming
> there's a reason we haven't implemented it?

It's contrary to standard.  There are some other reasons you can find
in the archives, too.

            regards, tom lane