Re: counting distinct rows on more than one column

From: Michael Fork <mfork(at)toledolink(dot)com>
To: Dirk Lutzebaeck <lutzeb(at)aeccom(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: counting distinct rows on more than one column
Date: 2001-03-28 16:12:42
Message-ID: Pine.BSI.4.21.0103281109001.9902-100000@glass.toledolink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In 7.0.3, I believe the following would work:

SELECT count(distinct(a || b)) FROM t;

if subselects in from were supported in 7.0.3 as they are in 7.1, you
could do:

SELECT count(*) FROM (SELECT DISTINCT a,b FROM t) FROM x

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Wed, 28 Mar 2001, Dirk Lutzebaeck wrote:

>
> Hi,
>
> on 7.0.3 want to COUNT
>
> SELECT DISTINCT a,b FROM t;
>
> I can't find a solution because any combination with
> count with more than one column gives syntax errors.
>
> One solution would be to set a view:
>
> CREATE VIEW v AS SELECT DISTINCT a,b FROM t;
>
> and then
>
> SELECT count(a) FROM v
>
> but views don't support distinct in v7.0.3
>
> Ok I could use a temporary table but my select distinct tends to give
> large results.
>
> Any clues?
>
> Dirk
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-03-28 16:17:55 Re: DELETE FROM fails with error
Previous Message Tom Lane 2001-03-28 16:10:51 Re: counting distinct rows on more than one column