Received: from sterling.betterhealthfoundation.net (user-112ugh2.biz.mindspring.com [66.47.66.34]) by postgresql.org (Postfix) with ESMTP id 6EFD8475803 for ; Wed, 31 Jul 2002 18:59:35 -0400 (EDT) Received: from dinar ([192.168.1.12]) by sterling.betterhealthfoundation.net with Microsoft SMTPSVC(5.0.2195.4905); Wed, 31 Jul 2002 15:59:37 -0700 From: "Tom Haddon" To: Subject: Case Statement Date: Wed, 31 Jul 2002 15:59:37 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-OriginalArrivalTime: 31 Jul 2002 22:59:37.0719 (UTC) FILETIME=[F1EB4870:01C238E5] X-Archive-Number: 200207/462 X-Sequence-Number: 8840 Hi Folks, Pretty basic one here. I'm trying to do a SELECT statement that includes a CASE structure that will be used in the ORDER BY clause, and I want the CASE structure to evaluate a bunch of criteria and in each case increment its value by a certain amount: SELECT id, description CASE field1 IS TRUE THEN CASE=CASE+1 field2 IS TRUE THEN CASE=CASE+2 END FROM table ORDER BY CASE, description; Am I misunderstanding what CASE can do here, and if so, how else do I do what I'm trying to do? I know that that isn't right - any pointers appreciated. Thanks, Tom