From: | Susan Cassidy <susan(dot)cassidy(at)decisionsciencescorp(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: way to custom sort column by fixed strings, then by field's content |
Date: | 2014-02-03 21:00:15 |
Message-ID: | CAE3Q8omYbiUvnGFSjyrwoxtHfM+asmQPGaaJyEJ+r+_Pe-TFZQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The query is currently:
select sti.description, sc.description from scene_thing_instances sti
left outer join scenes sc on sti.scene_id = sc.scene_id
order by sti.description, CASE
when (sti.description = 'absolute root'::text) then 1
when (sti.description ilike 'root%') then 2
else 3
END;
The results I want are:
description | description
-------------------+-------------
absolute root |
root 3 | Scene 1
root 4 | Scene 2
root 6 | Scene 3
18 cm long wrench | Scene 1
blue screwdriver | Scene 1
red toolbox | Scene 1
small wrench | Scene 1
tire | Scene 2
(9 rows)
On Mon, Feb 3, 2014 at 12:22 PM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>wrote:
> On 02/03/2014 12:01 PM, Susan Cassidy wrote:
>
> CCing the list.
>
> This didn't sort the way I want. It ended up as:
>> description | description
>> -------------------+-------------
>> 18 cm long wrench | Scene 1
>> absolute root |
>> blue screwdriver | Scene 1
>> red toolbox | Scene 1
>> root 3 | Scene 1
>> root 4 | Scene 2
>> root 6 | Scene 3
>> small wrench | Scene 1
>> tire | Scene 2
>>
>>
>> The first column is the one I want sorted.
>>
>
> Probably best to show us a made up sample of what you want.
>
>
>> Also note that I made it a left outer join\
>>
>
> Where?
>
>
>> Susan
>>
>>
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)gmail(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2014-02-03 21:27:26 | Re: way to custom sort column by fixed strings, then by field's content |
Previous Message | Ying He | 2014-02-03 20:51:23 | Re: pg_basebackup on standby node failed |