Re: MAX(column1),MAX(column2),...

Поиск
Список
Период
Сортировка
От Travis Hoyt
Тема Re: MAX(column1),MAX(column2),...
Дата
Msg-id DBEMKMGOMJAGKAKEPPEGEEJMDKAA.thoyt@npc.net
обсуждение исходный текст
Ответ на Re: MAX(column1),MAX(column2),...  ("Josh Berkus" <josh@agliodbs.com>)
Список 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@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
typingthe column
 
names, it doesn't exist.

-Josh Berkus

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: MAX(column1),MAX(column2),...
Следующее
От: Tom Lane
Дата:
Сообщение: Re: oid and oidvector