From: Jakub Ouhrabka <jouh8664@ss1000.ms.mff.cuni.cz>
To: pgsql-sql@postgresql.org
Subject: difficult query
Date: Sat, 4 May 2002 16:00:11 +0200 (CEST)
Message-ID: <Pine.LNX.4.33.0205041559440.17441-100000@u-pl2> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jouh8664@ss1000.ms.mff.cuni.cz
Subject: Re: difficult query
In-Reply-To: <Pine.LNX.4.33.0205041559440.17441-100000@u-pl2>
References: <Pine.LNX.4.33.0205041559440.17441-100000@u-pl2>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox