Re: xpath_string and group by

From: Arturo Perez <aperez(at)hayesinc(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: xpath_string and group by
Date: 2006-08-29 11:05:44
Message-ID: aperez-8D5C3B.07054029082006@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <20060829105458(dot)GB22806(at)svana(dot)org>,
kleptog(at)svana(dot)org (Martijn van Oosterhout) wrote:

> On Sat, Aug 26, 2006 at 03:51:06PM -0400, Perez wrote:
> > Hi all,
> >
> > Using 8.1.4 and contrib/xml2. When I do a
> >
> > select xpath_string(note, '//Thing') as note,
> > count(aDate) from theTable
> > group by lower(xpath_string(note, '//Thing'))
> > order by 2 desc;
> >
> > I get an error:
> > GROUP BY must contain note.
> > But I can do that for a plain text/varchar field. Adding the non-xpath
> > note field messes up the grouping.
>
> I wonder if it's getting confused about which "note" you're referring
> to in the GROUP BY clause.
>
> > select note, count(aDate) from
> > (select lower(xpath_string(note, '//Thing')) as note, aDate from
> > theTable) as foo
> > group by note
>
> This is about the same thing, so why not use that?
>
> Have a nice day,

You're right, it is almost the same thing. But the second form loses
the case of the original - everything is returned lower case. If I must
I must but I'ld like to preserve the case is possible.

-arturo

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2006-08-29 11:58:00 Re: speeding up big query lookup
Previous Message Martijn van Oosterhout 2006-08-29 10:54:58 Re: xpath_string and group by