Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 5C63E475A39 for ; Sat, 4 May 2002 11:44:33 -0400 (EDT) Received: from post.webmailer.de (natwar.webmailer.de [192.67.198.70]) by postgresql.org (Postfix) with ESMTP id B8AC0475A1A for ; Sat, 4 May 2002 11:44:31 -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 RAA21966; Sat, 4 May 2002 17:43:12 +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 17:44:48 +0200 X-Mailer: KMail [version 1.4] References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200205041744.48054.barwick@gmx.net> X-Archive-Number: 200205/23 X-Sequence-Number: 7659 On Saturday 04 May 2002 16:00, Jakub Ouhrabka wrote: > Hi, > > I'd like to ask how to write sql query returning following results without > using any other table than table1 (e.g. without outer join with table > containing all possible day numbers...) (...) > I'd like to write query returning this: > > query results: > day | number of records for a day > ---------------------- > 1 | 2 > 2 | 1 > 3 | 0 <--- !!! > 4 | 2 > > 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? Ian Barwick