Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 697A7475A5A for ; Sat, 4 May 2002 14:18:04 -0400 (EDT) Received: from post.webmailer.de (natwar.webmailer.de [192.67.198.70]) by postgresql.org (Postfix) with ESMTP id 38A66475A3D for ; Sat, 4 May 2002 14:18:03 -0400 (EDT) Received: from ianb (pD9517BA8.dip.t-dialin.net [217.81.123.168]) by post.webmailer.de (8.9.3/8.8.7) with ESMTP id UAA10402; Sat, 4 May 2002 20:17:58 +0200 (MEST) Content-Type: text/plain; charset="iso-8859-1" From: Ian Barwick To: Jakub Ouhrabka Subject: Re: difficult query Date: Sat, 4 May 2002 20:19:34 +0200 X-Mailer: KMail [version 1.4] Cc: References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200205042019.34265.barwick@gmx.net> X-Archive-Number: 200205/26 X-Sequence-Number: 7662 On Saturday 04 May 2002 19:34, Jakub Ouhrabka wrote: > > > Is it possible to do this in sql? > > > > Basically, no. (You might be able to do it with the help > > of a user-defined function though). > > > > Why do you want to do this? > > I'm curious. I've been on a sql course long time ago where the tutor > mentioned similiar problem as something special for sql smarties... And > yesterday when I faced this problem (which can be solved perfectly with > the outer join) I wasn't able to remember the solution... If there is > any... Just out of curiosity... well, you could do it like this I suppose: SELECT 1 AS day, COUNT(data) FROM table1 WHERE day=3D1=20 UNION=20 SELECT 2, COUNT(data) FROM table1 WHERE day=3D2 UNION=20 SELECT 3, COUNT(data) FROM table1 WHERE day=3D3 UNION=20 SELECT 4, COUNT(data) FROM table1 WHERE day=3D4 (and so on ad infinitum) although I expect E.F. Codd will be turning in his grave ;-) Ian Barwick