[SQL] adding "order by" to a "group by" query

2008-12-06 Thread Louis-David Mitterrand
Hi, This query: select p.id_person, person_name(p), array_accum(distinct pt.type_fr) from person p left join person_to_event x using (id_person) left join person_type pt using (id_person_type) where person_name(p) ilike '%wil

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Andreas Kretschmer
Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: > > But if I append this > >order by pt.type_fr = 'comédien'; > > I get this error: > > ERROR: column "pt.type_fr" must appear in the GROUP BY clause or be > used in an aggregate function > > It seems I am using pt.type_fr in

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Louis-David Mitterrand
On Sat, Dec 06, 2008 at 06:26:06PM +0100, Andreas Kretschmer wrote: > Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: > > > > But if I append this > > > > order by pt.type_fr = 'comédien'; > > > > I get this error: > > > > ERROR: column "pt.type_fr" must appear in the GROUP BY cla

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Scott Marlowe
On Sat, Dec 6, 2008 at 10:31 AM, Louis-David Mitterrand <[EMAIL PROTECTED]> wrote: > On Sat, Dec 06, 2008 at 06:26:06PM +0100, Andreas Kretschmer wrote: >> Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: >> > >> > But if I append this >> > >> > order by pt.type_fr = 'comédien'; >> > >> > I

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Andreas Kretschmer
Scott Marlowe <[EMAIL PROTECTED]> schrieb: > >> You can use a subquery like my example: > >> > >> test=*# select i, comma(t) from (select distinct i,t from foo) bar group > >> by i; > >> i | comma > >> ---+- > >> 1 | a, b, c > >> (1 row) > >> > >> Time: 0.554 ms > >> test=*# select i, c

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread John Lister
>(still curious about the "must be used in an aggregate function" error >though... because I do use it in an aggregate) You're original query grouped on the person id and name, therefore you can only return (and order by) these functions or the result of an aggregate function on other columns

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Louis-David Mitterrand
On Sat, Dec 06, 2008 at 06:24:25PM +, John Lister wrote: > >(still curious about the "must be used in an aggregate function" error > >though... because I do use it in an aggregate) > > You're original query grouped on the person id and name, therefore you > can only return (and order by) thes

[SQL] Public synonyms

2008-12-06 Thread Azzeddine Daddah
Hi guys, I'm new to Postgresql and I've a small question: Does Postgresql support public synonyms? Gr. Hbiloo

Re: [SQL] Public synonyms

2008-12-06 Thread Bruce Momjian
Azzeddine Daddah wrote: > Hi guys, > I'm new to Postgresql and I've a small question: > Does Postgresql support public synonyms? No, sorry, but it is a TODO item: Add support for public SYNONYMs -- Bruce Momjian <[EMAIL PROTECTED]>http://momjian.us EnterpriseDB