pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas F.O'Connell <tfo@sitening.com>
To: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: PgSQL - SQL <pgsql-sql@postgresql.org>
Subject: Re: Counting Distinct Records
Date: Wed, 17 Nov 2004 13:27:17 -0600
Message-ID: <B16EB296-38CE-11D9-95C2-000D93AE0944@sitening.com> (raw)
In-Reply-To: <20041117064813.V17486@megazone.bigpanda.com>
References: <1B2F7B00-3808-11D9-95C2-000D93AE0944@sitening.com>
	<20041116115807.E79990@megazone.bigpanda.com>
	<6E79C2FE-380B-11D9-95C2-000D93AE0944@sitening.com>
	<20041116141911.K84773@megazone.bigpanda.com>
	<A72D6B26-3823-11D9-95C2-000D93AE0944@sitening.com>
	<20041117064813.V17486@megazone.bigpanda.com>

The specific problem I'm trying to solve involves a user table with 
some history.

Something like this:

create table user_history (
	user_id int
	event_time_stamp timestamp
);

I'd like to be able to count the distinct user_ids in this table, even 
if it were joined to other tables.

-tfo

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005

On Nov 17, 2004, at 8:52 AM, Stephan Szabo wrote:

> On Tue, 16 Nov 2004, Thomas F.O'Connell wrote:
>
>> Hmm. I was more interested in using COUNT( * ) than DISTINCT *.
>>
>> I want a count of all rows, but I want to be able to specify which
>> columns are distinct.
>
> I'm now a bit confused about exactly what you're looking for in the 
> end.
> Can you give a short example?
>
>> That's definitely an interesting approach, but testing doesn't show it
>> to be appreciably faster.
>>
>> If I do a DISTINCT *, postgres will attempt to guarantee that there 
>> are
>> no duplicate values across all columns rather than a subset of 
>> columns?
>> Is that right?
>
> It guarantees one output row for each distinct set of column values 
> across
> all columns.




view thread (7+ messages)

Message-ID: <B16EB296-38CE-11D9-95C2-000D93AE0944@sitening.com>
Permalink:  ../B16EB296-38CE-11D9-95C2-000D93AE0944@sitening.com/
Also on:    postgresql.org/message-id/B16EB296-38CE-11D9-95C2-000D93AE0944@sitening.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tfo@sitening.com, sszabo@megazone.bigpanda.com
  Subject: Re: Counting Distinct Records
  In-Reply-To: <B16EB296-38CE-11D9-95C2-000D93AE0944@sitening.com>

* 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