From: Gaetano Mendola <mendola@bigfoot.com>
To: pgsql-sql@postgresql.org
Subject: Select the max on a field
Date: Thu, 12 Sep 2002 15:09:53 +0200
Message-ID: <alq3mr$2s7o$1@news.hub.org> (raw)
Hi all,
Suppose that I have a table like this:
att_1 | att_2 | att_3 | att_4
--------------------------------
1 | a | y | y1
2 | b | y | y2
3 | a | xx | y3
4 | c | zz | y4
5 | a | t | y5
6 | c | x | y6
I want obtain all row that have for each att_2
the max of att_1
some like
SELECT *
FROM MY_TABLE
GROUP BY att_2
HAVING att_1 = max ( id_user_log)
for obtain:
att_1 | att_2 | att_3 | att_4
--------------------------------
2 | b | y | y2
5 | a | t | y5
6 | c | x | y6
Ciao
Gaetano
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: mendola@bigfoot.com
Subject: Re: Select the max on a field
In-Reply-To: <alq3mr$2s7o$1@news.hub.org>
* 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