12 | | == |
| 12 | |
| 13 | === Извештај за најпозајмени книги === |
| 14 | {{{$!sql |
| 15 | SELECT book.CoverImage, book.Title, book.Genre, author.FirstName, author.LastName, COUNT(loan.LoanID) AS loan_count FROM book |
| 16 | INNER JOIN book_copies ON book.BookID = book_copies.BookID |
| 17 | LEFT JOIN loan ON book_copies.CopyID = loan.BookCopyID |
| 18 | INNER JOIN book_author ON book.BookID = book_author.BookID |
| 19 | INNER JOIN author ON book_author.AuthorID = author.AuthorID |
| 20 | GROUP BY book.BookID, book.Title, book.CoverImage, book.Genre, author.FirstName, author.LastName |
| 21 | ORDER BY loan_count DESC LIMIT 5; |
| 22 | }}} |
| 23 | |
| 24 | === Извештај за најмалку позајмувани книги === |
| 25 | {{{$!sql |
| 26 | SELECT book.CoverImage, book.Title, book.Genre, author.FirstName, author.LastName, COUNT(loan.LoanID) AS loan_count FROM book |
| 27 | INNER JOIN book_copies ON book.BookID = book_copies.BookID |
| 28 | LEFT JOIN loan ON book_copies.CopyID = loan.BookCopyID |
| 29 | INNER JOIN book_author ON book.BookID = book_author.BookID |
| 30 | INNER JOIN author ON book_author.AuthorID = author.AuthorID |
| 31 | GROUP BY book.BookID, book.Title, book.CoverImage, book.Genre, author.FirstName, author.LastName |
| 32 | ORDER BY loan_count ASC LIMIT 5; |
| 33 | }}} |