X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 66E39D1E7ED for ; Sat, 24 Jan 2004 07:24:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 97849-03 for ; Sat, 24 Jan 2004 03:24:03 -0400 (AST) Received: from smtp.inreach.com (smtp.inreach.com [209.142.2.34]) by svr1.postgresql.org (Postfix) with SMTP id 0A8BFD1E407 for ; Sat, 24 Jan 2004 03:24:01 -0400 (AST) Received: (qmail 29929 invoked from network); 24 Jan 2004 07:24:01 -0000 Received: from unknown (HELO newmicronpc) (209.209.15.168) by smtp.inreach.com with SMTP; 24 Jan 2004 07:24:01 -0000 Message-Id: <3.0.5.32.20040123222437.009f3b60@mail.northcoast.com> X-Sender: darnold@mail.northcoast.com (Unverified) X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.5 (32) Date: Fri, 23 Jan 2004 22:24:37 -0800 To: pgsql-sql@postgresql.org From: David Arnold Subject: An order by question Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200401/295 X-Sequence-Number: 16688 All, I need a little help on a sorting problem. Imagine a table, call it records, that has fields: lastName firstName term I want to sort the records by last name, then first name, and finally by term. This almost does what I want: select * from records order by lastName, firstName, term; However, the possible values for term are: 2002F 2003S 2003X 2003F Where F is for fall, S for spring, and X for summer session. Thus, a straight alphabetical sort doesn't give me what I want. If the year is the same, then I want a sort with S, then X, then F for identical year. Any suggestions?