From: | "Travis Hoyt" <thoyt(at)npc(dot)net> |
---|---|
To: | "Josh Berkus" <josh(at)agliodbs(dot)com>, "Bjarte Aagnes" <bjartea(at)student(dot)sv(dot)uio(dot)no>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: MAX(column1),MAX(column2),... |
Date: | 2002-04-15 20:17:10 |
Message-ID: | DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice pgsql-sql |
You could write a plpgsql function to select all the column names from the
one of the system tables and do max($myvar) for each of the column names
returned.
select attname from pg_stats where tablename = 'yourtablename';
Will get you the list of columns. Just write a loop the loop through each
one and do max().
Travis
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org]On Behalf Of Josh Berkus
Sent: Monday, April 15, 2002 3:34 PM
To: Bjarte Aagnes; pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] MAX(column1),MAX(column2),...
Bjarte,
> How do I list all column names and maximum values for each column in
> a table.
> I can list the column names, but can't see how to get the maximum of
> each
> column without typing max(name) for every column.
That is exactly what you have to do. I do not understand the problem.
If you are looking for some way to save yourself typing the column
names, it doesn't exist.
-Josh Berkus
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Post | 2002-04-15 21:53:48 | Pl/Pgsql function troubles |
Previous Message | Josh Berkus | 2002-04-15 19:34:14 | Re: MAX(column1),MAX(column2),... |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-04-15 20:36:57 | Re: oid and oidvector |
Previous Message | Josh Berkus | 2002-04-15 19:34:14 | Re: MAX(column1),MAX(column2),... |