From: | "Zuev Dmitry" <envoy1(at)chat(dot)ru> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | help on sql query |
Date: | 2002-11-26 13:14:07 |
Message-ID: | arvs7m$fpf$1@news.nsk.su |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
__________________________________________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Rison, Stuart | 2002-11-26 13:54:03 | [SQL/BUGS] (possible) inconsistent behaviour of timestamp? |
Previous Message | Albrecht Berger | 2002-11-26 12:55:51 | Inheritance in SQL99 ? |