Subject Re: [firebird-support] Re: SQL-question, something like FOR or Aggregate?
Author John vd Waeter
That's the one!
Thanks alot, Set!

Kind regards,
John


Svein Erling Tysvær wrote:
> Hi John!
>
> Theoretical questions are normally quite simple:
>
> select b.Genre, b.ID, b.Title, b.Author
> from books b
> where not exists(select * from books b1
> where b1.Genre = b.Genre
> and b1.DateOfSubmission > b.DateOfSubmission)
>
> This will, of course, give you several books in the same Genre if the
> DateOfSubmission is the same. Such problems are normally easily
> avoided by comparing a unique value in case of duplicates, e.g.
>
> select b.Genre, b.ID, b.Title, b.Author
> from books b
> where not exists(select * from books b1
> where b1.Genre = b.Genre
> and ((b1.DateOfSubmission > b.DateOfSubmission) or
> (b1.DateOfSubmission = b.DateOfSubmission and
> b1.ID > b.ID))
>
> This should help you get started,
> Set