Re: max(*) - Mailing list pgsql-hackers

From Robert Treat
Subject Re: max(*)
Date
Msg-id 200605261932.14722.xzilla@users.sourceforge.net
Whole thread Raw
In response to Re: max(*)  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
List 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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Updatable views/with check option parsing
Next
From: "Andrew Dunstan"
Date:
Subject: Re: Updatable views/with check option parsing