Subject Re: Highest and Second highest values
Author Adam
--- In firebird-support@yahoogroups.com, David Johnson
<johnson_d@...> wrote:
>
> I take that back ... vanilla SQL doesn't handle that well.
Firebird SQL
> supports the FIRST predicate, so I'm barking up a tree.

FB 2 and some other DBs also support the ROWS syntax which could
achieve the same thing. Others have the keyword limit to do the same
thing.

If you are a sadist, You may even be able to use union and a pretty
terrible looking query to do it with plain vanilla.


Adam


>
> On Fri, 2006-03-24 at 03:11 +0000, Adam wrote:
> > > Is it possible to select both the max and next max value in a
table
> > using
> > > dsql? Ie the 2 highest values in a tables column.
> >
> > Easy.
> >
> > select first 2 *
> > from mytable
> > order by myvalue desc
> >
> > A descending index on myvalue is useful if the table is large.
> >
> >
> > Adam
>