I have two tables. Books and bookPages. What would be the query that would hand me
back the pageId of all pages that are the last page in the book. Basically I would want all pageId's
in all distinct books that claim to be the last page of the book
Book BookPages
bookName bookId
bookId pageNumber
pageId
Here is some example data for the Book table
bookName bookId
'myBook1' 1
'myBook2' 2
'myBook3' 3
Here is some example data for the Book Pages table
bookId pageNumber pageId
1 1 20
1 2 21
1 3 23
2 1 24
2 2 25
2 3 26
2 4 27
Here are the results that I want
bookId pageNumber pageId
1 3 23
2 4 27
back the pageId of all pages that are the last page in the book. Basically I would want all pageId's
in all distinct books that claim to be the last page of the book
Book BookPages
bookName bookId
bookId pageNumber
pageId
Here is some example data for the Book table
bookName bookId
'myBook1' 1
'myBook2' 2
'myBook3' 3
Here is some example data for the Book Pages table
bookId pageNumber pageId
1 1 20
1 2 21
1 3 23
2 1 24
2 2 25
2 3 26
2 4 27
Here are the results that I want
bookId pageNumber pageId
1 3 23
2 4 27