Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > ORDER BY Clause
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3071 of 3177
Post > Topic >>

ORDER BY Clause

by list@[EMAIL PROTECTED] (Derrick Betts) Apr 12, 2008 at 08:52 PM

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


-- 
Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 




 3 Posts in Topic:
ORDER BY Clause
list@[EMAIL PROTECTED] (  2008-04-12 20:52:38 
Re: ORDER BY Clause
fbax@[EMAIL PROTECTED] (  2008-04-13 00:06:01 
Re: ORDER BY Clause
list@[EMAIL PROTECTED] (  2008-04-13 12:38:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 5:13:39 CDT 2008.