Re: count() and multiple tables

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, Joseph Shraibman <jks(at)selectacast(dot)net>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: count() and multiple tables
Date: 2001-03-20 04:46:39
Message-ID: web-27008@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan, Joseph,

> Because d.id was guaranteed to be unique, you might be able to
> count(distinct d.id) and get the result you want. [I think the
> subquery is a nicer way of representing it]

Plus a several SQL implementations don't implement the DISTINCT until
after the COUNT, reuslting in a still-inflated (and sometimes varying!)
COUNT. It won't work properly in T-SQL or MS Office SQL, for example.

-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rachel Coin 2001-03-20 08:48:21 Categories and subcategories
Previous Message Joseph Shraibman 2001-03-20 02:05:26 Re: VACUUM kills Index Scans ?!