agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Zuev Dmitry <envoy1@chat.ru>
To: pgsql-sql@postgresql.org
Subject: help on sql query
Date: Tue, 26 Nov 2002 19:14:07 +0600
Message-ID: <arvs7m$fpf$1@news.nsk.su> (raw)
Suppose you have a table T:
----------------------
A B
----------------------
1 '111'
2 '222'
----------------------
How do you select A and B of the record with A maximum?
The desirable result therefore is (2, '222')
The two variants I could grow with are:
1) SELECT A, B FROM T ORDER BY A DESC LIMIT 1
2) SELECT A, B FROM T WHERE A IN (SELECT MAX(A) FROM T)
What do yo think of the queries above? And give me the better implementation
if possible.
__________________________________________________________________ Dmitry
Vitalievitch ICQ#: 11000008 Current ICQ status: + More ways to contact me
__________________________________________________________________
view thread (7+ messages) latest in thread
Message-ID: <arvs7m$fpf$1@news.nsk.su>
Permalink: ../arvs7m$fpf$1@news.nsk.su/
Also on: postgresql.org/message-id/arvs7m$fpf$1@news.nsk.su
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: envoy1@chat.ru
Subject: Re: help on sql query
In-Reply-To: <arvs7m$fpf$1@news.nsk.su>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox