Re: DISTINCT ordering

From: Jake Stride <nsuk(at)users(dot)sourceforge(dot)net>
To: Ron St-Pierre <rstpierre(at)syscor(dot)com>, 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 17:32:16
Message-ID: BD3EC530.187A%nsuk@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 10/8/04 4:56 pm, "Ron St-Pierre" <rstpierre(at)syscor(dot)com> wrote:

> 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);

Because I don¹t want the name in lower case, what I want is

The
the
Z

not:

The
Z
the

>
> otherwise something like:
> SELECT lower (SS.name) FROM (SELECT DISTINCT name FROM someview) SS ORDER BY
> lower(name);

This is what I have at present, although slightly adjusted, but I wanted to
know if it was possible without 2 selects,

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

Jake

> would return 'foo' twice in the output.
>
>
> Ron
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David.Ventimiglia 2004-08-10 17:44:24 PGADMIN III Tools disabled w/ PostgreSQL 8.0 pginstaller
Previous Message Eduardo Vázquez Rodríguez 2004-08-10 16:59:47 Re: Query result to a file