X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 08E76474E5C for ; Sun, 9 Feb 2003 17:31:46 -0500 (EST) Received: from smtp7.andrew.cmu.edu (SMTP7.andrew.cmu.edu [128.2.10.87]) by postgresql.org (Postfix) with ESMTP id 608DB474E53 for ; Sun, 9 Feb 2003 17:31:45 -0500 (EST) Received: from cmu.edu (AXMINSTER.WV.CC.cmu.edu [128.2.67.79]) (user=amcauley mech=PLAIN (0 bits)) by smtp7.andrew.cmu.edu (8.12.3.Beta2/8.12.3.Beta2) with ESMTP id h19MViBI032095 (version=TLSv1/SSLv3 cipher=DES-CBC3-SHA bits=168 verify=NOT) for ; Sun, 9 Feb 2003 17:31:44 -0500 Date: Sun, 9 Feb 2003 17:29:29 -0500 Mime-Version: 1.0 (Apple Message framework v551) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: order by date desc but NULLs last From: "A.M." To: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.551) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/179 X-Sequence-Number: 11577 I have a simple query that sorts by descending date but the NULL dates show up first. Is there a way I can sort so they come last without sorting ascending? SELECT submittime,score,gradedtime FROM student_gradedmaterial WHERE gradedmaterialid=3 and studentid=102 order by gradedtime desc; submittime | score | gradedtime ---------------------+-------+---------------------------- 2003-01-30 22:56:38 | | 2003-01-31 03:42:29 | 99 | 2003-02-06 14:21:43.043587 but what I want is all the graded items first in gradedtime desc and NULL afterwards. I do need to keep the NULL score rows. (So I get the latest submitted grade for the assignment but also any ungraded submission information.) Thanks for any advice. ><><><><><><><><>< AgentM agentm@cmu.edu