Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 82C664758E6 for ; Sat, 4 May 2002 10:00:19 -0400 (EDT) Received: from ss1000.ms.mff.cuni.cz (ss1000.ms.mff.cuni.cz [195.113.19.221]) by postgresql.org (Postfix) with ESMTP id 53B93475887 for ; Sat, 4 May 2002 10:00:18 -0400 (EDT) Received: from u-pl2.ms.mff.cuni.cz (u-pl2.ms.mff.cuni.cz [195.113.21.162]) by ss1000.ms.mff.cuni.cz (Postfix) with ESMTP id E44921CFB1 for ; Sat, 4 May 2002 16:00:11 +0200 (CEST) Received: by u-pl2.ms.mff.cuni.cz (Postfix, from userid 18664) id B8AACCD02; Sat, 4 May 2002 16:00:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by u-pl2.ms.mff.cuni.cz (Postfix) with ESMTP id B1D41CCD5 for ; Sat, 4 May 2002 16:00:11 +0200 (CEST) Date: Sat, 4 May 2002 16:00:11 +0200 (CEST) From: Jakub Ouhrabka X-X-Sender: To: Subject: difficult query Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200205/22 X-Sequence-Number: 7658 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...) table1: day | data ------------ 1 | x 1 | x 2 | x 4 | x 4 | x 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? thanks a lot, kuba