X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 690A3474E5C for ; Mon, 10 Feb 2003 01:19:44 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id D0DE8474E53 for ; Mon, 10 Feb 2003 01:19:43 -0500 (EST) Received: from lamer.pl (localhost [127.0.0.1]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id 3C2B32B87F; Mon, 10 Feb 2003 07:12:11 +0100 (CET) From: "Tomasz Myrta" To: "A.M." , pgsql-sql@postgresql.org Subject: Re: order by date desc but NULLs last Date: Mon, 10 Feb 2003 07:12:11 +0800 Message-Id: <20030210071211.M27958@klaster.net> In-Reply-To: References: X-Mailer: Open WebMail 1.62 20020221 X-OriginatingIP: 217.96.97.138 (jasiek) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/184 X-Sequence-Number: 11582 > 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 order by gradetime is null asc, gradetime desc; Regards, Tomasz Myrta