Subject | Re: [firebird-support] Re: MAX function |
---|---|
Author | Tim |
Post date | 2008-02-26T07:21:28Z |
Thanks Adam. Worked like a charm. :D
At 08:30 26/02/2008, you wrote:
At 08:30 26/02/2008, you wrote:
>--- In[Non-text portions of this message have been removed]
><mailto:firebird-support%40yahoogroups.com>firebird-support@yahoogroups.com,
>Tim <tim@...> wrote:
> >
> > My apologies to all who have been kind enough to answer my questions.
> >
> > I should have pointed out that I was aware that there were syntax
> > errors, and that I would need to fix them. Your answers have been
> > helpful in reminding me how variables and IF statements should be
>structured.
> >
> > What i am more interested in, however, is how to solve the following
>problem :
> >
> > "I need to get a field value dependant on the maximum of another
>field value.
> >
> > For example in the following case, I want the BATCH NUMBER value for
> > the maximum RECORDNO value."
> >
> > If I try "SELECT MAX(RECORDNO), BATCHNO FROM BATCH then I have to use
> > the GROUP BY clause. The problem with that is that I get a result set
> > with multiple rows.
> >
> > What I would like is a singleton result set, which for the maximum
> > RECORDNO will give me the corresponding BATCHNO.
> >
> > Any ideas?
> >
> > Thanks, and apologies once again
> >
> > Tim
> >
>
>Hi Tim,
>
>SELECT FIRST 1 RECORDNO, BATCHNO
>FROM BATCH
>ORDER BY RECORDNO DESC
>
>Adam
>
>