Skip site navigation (1) Skip section navigation (2)

Sub select..

From: "Ed" <dziablo(at)lords(dot)com>
To: "pgsql sql" <pgsql-sql(at)postgresql(dot)org>
Subject: Sub select..
Date: 2000-03-31 21:11:13
Message-ID: 000301bf9b55$a511dd00$b48c29d1@citenet.net (view raw or flat)
Thread:
Lists: pgsql-sql
Hi,

I would like to know if ther is a way of doing something like this :

select max(col1) from (select count(*) as col1 from table1 where index_field
= 3 group by day);

table1 loking like :

day    |   index_field   | ...
-------------------------------------
1                1
1                1
1                3
1                3
2                3
3                1
3                3



Finally, I only want to know the maximum count(*) value grouped by day

my sub query should return me :

col1
-------
2      (for day 1)
1       (for day 2)
1       (for day 3)

So, Max(col1) would return me " 2 "

but... imbriqued select doesn't seems to work in 6.5.3....

Any suggestions?

/fb



pgsql-sql by date

Next:From: S KalyanasundaramDate: 2000-03-31 22:47:22
Subject: Stored Procedures..
Previous:From: Peter EisentrautDate: 2000-03-31 13:55:20
Subject: Re: outer join syntax

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group