Re: DISTINCT ordering

From: Ron St-Pierre <rstpierre(at)syscor(dot)com>
To: Jake Stride <nsuk(at)users(dot)sourceforge(dot)net>, pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: DISTINCT ordering
Date: 2004-08-10 15:56:54
Message-ID: 4118F046.8050303@syscor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Jake Stride wrote:

>I have a view from which I select values, but I need to do a 'SELECT
>DISTINCT' query on a 'varchar' column and order by lower case eg:
>
>SELECT DISTINCT name FROM someview ORDER BY lower(name)
>
If this is what you want, wouldn't 'Foo' and 'foo' both show up in your
output? If you only wanted one 'foo' you could use:

SELECT DISTINCT lower(name) FROM someview ORDER BY lower(name);

otherwise something like:
SELECT lower (SS.name) FROM (SELECT DISTINCT name FROM someview) SS ORDER BY lower(name);
would return 'foo' twice in the output.

Ron

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Ron St-Pierre 2004-08-10 16:03:00 Re: Script done... Function won´t wo
Previous Message Eduardo Vázquez Rodríguez 2004-08-10 15:29:43 Query result to a file