0

There is an error.

You are working with a library database that stores data on books. The Books table has the columns id, name, year, author_id. The author_id column connects to the Authors table, which stores the id, name columns for the book authors. You need to select all the books with their authors, ordered by the author name alphabetically, then by the year in ascending order. The result set should contain only 3 columns: the book name, year and its author (name the column author). SELECT Books.name AS book_name, Books.year, Authors.name AS author FROM Books, Authors WHERE Books.author_id = Authors.id ORDER BY Authors.name ASC, Books.year ASC; The Test Case is not working fine.

4th May 2024, 12:44 PM
Div Anand
Div Anand - avatar
3 Answers
+ 2
Please be specific what sort of error you are facing, don't let people guess. I believe it is the final task in SQL Intermediate, Multiple Tables. The description says: The result set should contain only 3 columns: the book name, year and its author (name the column author). It asks for a column named as author, as you did, but it didn't ask to rename the book name column...
4th May 2024, 2:13 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
Can you help me with the code?SELECT Books.name AS book_name, Books.year, Authors.name AS author FROM Books,Authors WHERE Books.author_id = Authors.id ORDER BY Authors.name ASC, Books.year ASC; This is the code.
4th May 2024, 3:05 PM
Div Anand
Div Anand - avatar
0
Div Anand I already gave you a hint in previous answer. More specifically, only one column has to rename, but you renamed two.
4th May 2024, 3:09 PM
Wong Hei Ming
Wong Hei Ming - avatar