pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Travis Hoyt <thoyt@npc.net>
To: Josh Berkus <josh@agliodbs.com>
To: Bjarte Aagnes <bjartea@student.sv.uio.no>
To: pgsql-sql@postgresql.org
Subject: Re: MAX(column1),MAX(column2),...
Date: Mon, 15 Apr 2002 16:17:10 -0400
Message-ID: <DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net> (raw)
In-Reply-To: <web-1371121@davinci.ethosmedia.com>

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@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Josh Berkus
Sent: Monday, April 15, 2002 3:34 PM
To: Bjarte Aagnes; pgsql-sql@postgresql.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?

http://archives.postgresql.org

Attachments:

  smime.p7s (application/x-pkcs7-signature, 3.0K) download

view thread (4+ messages)  latest in thread

Message-ID: <DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net>
Permalink:  ../DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net/
Also on:    postgresql.org/message-id/DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: thoyt@npc.net, josh@agliodbs.com, bjartea@student.sv.uio.no
  Subject: Re: MAX(column1),MAX(column2),...
  In-Reply-To: <DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox