Query Problem!!

Started by PostgreSQL Bugs Listabout 25 years ago4 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Christian Gonzalez (christiangda@cantv.net) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Query Problem!!

Long Description
I have problem with the GROUP BY

Sample Code
select name, 'user' as class from smuser union select name, 'group' as class from smgroup order by class;

No file was uploaded with this report

#2Peter Eisentraut
peter_e@gmx.net
In reply to: PostgreSQL Bugs List (#1)
Re: Query Problem!!

pgsql-bugs@postgresql.org writes:

I have problem with the GROUP BY

But which is it???

--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/

#3Yoshihiko Ichikawa
ichikawa@is.ocha.ac.jp
In reply to: Peter Eisentraut (#2)
Re: Query Problem!!

On Mon, 8 Jan 2001 15:50:42 -0400, <christiangda@cantv.net> wrote:

I have PostgreSQL v7.02 in RedHat 6.2;

I have problem with is Query:
select name, 'user' as class from smuser union select name, 'group' as class from smgroup order by class;

sentence problem is:{ order by class} !!!!

thank you,
Christian Gonzalez

Hi. This is because ``class'' is one of the reserved keywords of
PostgreSQL. You can avoid this problem by using quoted identifiers
like

select name, 'user' as "class" from smuser ...,

or simply rename the attribute.

-----
Yoshihiko Ichikawa
Department of Information Sciences, Ochanomizu University
Phone: +81-3-5978-5708; Fax: +81-3-5978-5705
E-mail: ichikawa@is.ocha.ac.jp

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Yoshihiko Ichikawa (#3)
Re: Query Problem!!

<christiangda@cantv.net> writes:

<DIV><FONT face=3DArial size=3D2>I have PostgreSQL v7.02 in RedHat 6.2;</FO=

NT> </DIV>

<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have problem with is Query:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>select name, 'user' as class from smuser u=
nion=20
select name, 'group' as class from smgroup order by class;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>

Please turn off HTML mail :-(

The problem is with the nonspecific-type literals; 7.0 won't resolve
those to a particular datatype by itself, so it doesn't know how to sort
them. Try

select name, 'user'::text as class from smuser
union
select name, 'group'::text as class from smgroup
order by class;

regards, tom lane