Article View: borland.public.interbase.sql
Article #11376Re: Selecting row in which a column value is maximum
From: Edward Diener
Date: Mon, 25 Nov 2002 16:03
Date: Mon, 25 Nov 2002 16:03
21 lines
1811 bytes
1811 bytes
"Craig Stuntz [TeamB]" <cstuntz@nospamplease.com (but use vertexsoftware to email)> wrote in message news:MPG.184c120210a6b55a98a253@newsgroups.borland.com... > In article <3de0d0f0$1@newsgroups.borland.com>, "Arno Brinkman" > <bnewsgroups @ abvisie.nl> says... > > SELECT > > * > > FROM > > ATable > > WHERE > > ATable.AField = (SELECT MAX(AField) FROM ATable) > > > > I'm afraid that the above query will be slow, so it's faster to use an SP. > > > Shouldn't be a problem if there's a DESCENDING INDEX on > ATable.AField. I don't see what the difference between a descending and ascending index is in this situation. I think the key point is that there be an index so that each row doesn't have to be read to find the maximum value.
Technical Details
Message-ID:
<3de24925@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3de051cf@newsgroups.borland.com> <3de0d0f0$1@newsgroups.borland.com> <MPG.184c120210a6b55a98a253@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114a0e,60a1aedc82f6444 X-Google-Attributes: gid114a0e,public X-Google-ArrivalTime: 2002-11-25 08:06:42 PST From: "Edward Diener" <eddielee@tropicsoft.com> Newsgroups: borland.public.interbase.sql References: <3de051cf@newsgroups.borland.com> <3de0d0f0$1@newsgroups.borland.com> <MPG.184c120210a6b55a98a253@newsgroups.borland.com> Subject: Re: Selecting row in which a column value is maximum Date: Mon, 25 Nov 2002 11:03:23 -0500 Lines: 23 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 66.32.65.244 Message-ID: <3de24925@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1038240037 66.32.65.244 (25 Nov 2002 08:00:37 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail