From: | Derrick Betts <list(at)blueaxis(dot)com> |
---|---|
To: | "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org> |
Subject: | ORDER BY Clause |
Date: | 2008-04-13 02:52:38 |
Message-ID: | 48017576.6070607@blueaxis.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I have a query: SELECT fruit, group_number, ordering_number FROM
fruit_groups ORDER BY group_number, order_number;
The results look like:
fruit | group_number | ordering_number
--------+------------------+-------------------
cherry | 1 | 1
orange | 1 | 2
apple | 2 | 1
pear | 2 | 2
banana | 3 | 1
kiwi | 3 | 2
I would like the results to look like:
fruit | group_number | ordering_number
--------+------------------+-------------------
apple | 2 | 1
orange | 2 | 2
banana | 3 | 1
kiwi | 3 | 2
cherry | 1 | 1
orange | 1 | 2
I want the group_number to be grouped together, then sorted by the
ordering_number, then listed in the output alphabetically by the fruit
name listed first in the group_number (as defined by the ordering_number).
Does anyone know how I might modify my statement to get this ordering?
Thanks,
Derrick
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2008-04-13 04:06:01 | Re: ORDER BY Clause |
Previous Message | Jaisen N.D. | 2008-04-12 05:21:45 | problem with 8.1: createdb: could not connect to database postgres: could not connect to server: No such file or directory |