Re: max(*)

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, "Dennis Bjorklund" <db(at)zigo(dot)dhs(dot)org>
Subject: Re: max(*)
Date: 2006-05-26 23:32:14
Message-ID: 200605261932.14722.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday 26 May 2006 09:45, Gurjeet Singh wrote:
> Something not supported should be stated as such through an ERROR. Except
> for count(), none of the following make any sense:
>
> The transcipt:
>
> test=# \d t1
> Table "public.t1"
> Column | Type | Modifiers
> --------+---------+-----------
> a | integer | not null
> Indexes:
> "t1_pkey" PRIMARY KEY, btree (a)
>
> test=# select * from t1;
> a
> ---
> 1
> 2
> 3
> 4
> 5
> (5 rows)
>

given:

pagila=# select 1 from t1;
?column?
----------
1
1
1
1
1
(5 rows)

> test=# select count(*) from t1;
> count
> -------
> 5
> (1 row)
>

this makes sense

> test=# select count(1) from t1;
> count
> -------
> 5
> (1 row)
>

and so does this

> test=# select max(*) from t1;
> max
> -----
> 1
> (1 row)
>

not so much

> test=# select max(1) from t1;
> max
> -----
> 1
> (1 row)
>

but this does

> test=# select min(*) from t1;
> min
> -----
> 1
> (1 row)
>

not here though

> test=# select avg(*) from t1;
> avg
> ------------------------
> 1.00000000000000000000
> (1 row)
>

nor here

> test=# select sum(*) from t1;
> sum
> -----
> 5
> (1 row)
>

or here

> test=# select sum(1) from t1;
> sum
> -----
> 5 <--- this is correct
> (1 row)
>
> test=#

yep... but really most aggregates are ok with a 1

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

In response to

  • Re: max(*) at 2006-05-26 13:45:54 from Gurjeet Singh

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Woodward 2006-05-26 23:32:43 Re: LIKE, leading percent, bind parameters and indexes
Previous Message Tom Lane 2006-05-26 23:26:44 Re: Updatable views/with check option parsing