Subject | Re: MAX function |
---|---|
Author | Adam |
Post date | 2008-02-26T06:30:18Z |
--- In firebird-support@yahoogroups.com, Tim <tim@...> wrote:
SELECT FIRST 1 RECORDNO, BATCHNO
FROM BATCH
ORDER BY RECORDNO DESC
Adam
>structured.
> 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
>problem :
> What i am more interested in, however, is how to solve the following
>field value.
> "I need to get a field value dependant on the maximum of another
>Hi Tim,
> 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
>
SELECT FIRST 1 RECORDNO, BATCHNO
FROM BATCH
ORDER BY RECORDNO DESC
Adam