Received: from hotmail.com (f26.law3.hotmail.com [209.185.241.26]) by postgresql.org (Postfix) with ESMTP id 6DFE3476562 for ; Mon, 15 Apr 2002 06:44:03 -0400 (EDT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 15 Apr 2002 03:44:05 -0700 Received: from 24.79.100.181 by lw3fd.law3.hotmail.msn.com with HTTP; Mon, 15 Apr 2002 10:44:05 GMT X-Originating-IP: [24.79.100.181] From: "Dorian Taylor" To: pgsql-sql@postgresql.org Subject: case statement in group by clause Date: Mon, 15 Apr 2002 10:44:05 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 15 Apr 2002 10:44:05.0817 (UTC) FILETIME=[770E3290:01C1E46A] X-Archive-Number: 200204/175 X-Sequence-Number: 7439 Greetings, I can't remember if I asked the list this before (it's been a very hectic month), if so, please disregard. I'm trying to find the most elegant way of integrating SQL into an application I am writing which has a potential for N^3*M fairly similar queries (Luckily enough N is 3 and M is 6, but could easily and very soon become more). Rather than explicitly write each of these out, or concoct some sort of illegible mutant string-concatenation/bind parameter frankenstein, I would like to simply create one massive query riddled with case statements triggered by named bind parameters. What is holding me back from this is the inability to coerce certain column types in a case statement in a GROUP BY clause. Now, the obvious solution would be to flatten each test out to return a value of the same type, although I'm not too sure how to access the original sorting function/operator that is associated with a GROUP BY clause. I'm sure this isn't a new problem, but I've run into great difficulty finding anything on the subject. Please advise. Regards, Dorian _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com