Changes between Version 11 and Version 12 of Напредни извештаи од базата (SQL и складирани процедури)
- Timestamp:
- 01/11/25 16:16:10 (4 days ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Напредни извештаи од базата (SQL и складирани процедури)
v11 v12 20 20 }}} 21 21 22 === Извештај за најпозајмени книги ===22 === Извештај за најпозајмени книги по тримесечие === 23 23 {{{#!sql 24 SELECT book.CoverImage, book.Title, book.Genre, author.FirstName, author.LastName, COUNT(loan.LoanID) AS loan_count FROM book 24 SELECT 25 book.CoverImage, 26 book.Title, 27 book.Genre, 28 author.FirstName, 29 author.LastName, 30 EXTRACT(QUARTER FROM loan.LoanDate) AS quarter, 31 COUNT(loan.LoanID) AS loan_count 32 FROM book 25 33 INNER JOIN book_copies ON book.BookID = book_copies.BookID 26 34 LEFT JOIN loan ON book_copies.CopyID = loan.BookCopyID 27 35 INNER JOIN book_author ON book.BookID = book_author.BookID 28 36 INNER JOIN author ON book_author.AuthorID = author.AuthorID 29 GROUP BY book.BookID, book.Title, book.CoverImage, book.Genre, author.FirstName, author.LastName 30 ORDER BY loan_count DESC LIMIT 5; 37 WHERE EXTRACT(QUARTER FROM loan.LoanDate) = 4 -- Change this number (1-4) for different quarters 38 GROUP BY 39 book.BookID, 40 book.Title, 41 book.CoverImage, 42 book.Genre, 43 author.FirstName, 44 author.LastName, 45 EXTRACT(QUARTER FROM loan.LoanDate) 46 ORDER BY loan_count DESC 47 LIMIT 5; 31 48 }}} 32 49 33 === Извештај за најмалку позајмувани книги ===50 === Извештај за најмалку позајмувани книги по тримесечие === 34 51 {{{#!sql 35 SELECT book.CoverImage, book.Title, book.Genre, author.FirstName, author.LastName, COUNT(loan.LoanID) AS loan_count FROM book 52 SELECT 53 book.CoverImage, 54 book.Title, 55 book.Genre, 56 author.FirstName, 57 author.LastName, 58 EXTRACT(QUARTER FROM loan.LoanDate) AS quarter, 59 COUNT(loan.LoanID) AS loan_count 60 FROM book 36 61 INNER JOIN book_copies ON book.BookID = book_copies.BookID 37 62 LEFT JOIN loan ON book_copies.CopyID = loan.BookCopyID 38 63 INNER JOIN book_author ON book.BookID = book_author.BookID 39 64 INNER JOIN author ON book_author.AuthorID = author.AuthorID 40 GROUP BY book.BookID, book.Title, book.CoverImage, book.Genre, author.FirstName, author.LastName 41 ORDER BY loan_count ASC LIMIT 5; 65 WHERE EXTRACT(QUARTER FROM loan.LoanDate) = 4 -- Change this number (1-4) for different quarters 66 GROUP BY 67 book.BookID, 68 book.Title, 69 book.CoverImage, 70 book.Genre, 71 author.FirstName, 72 author.LastName, 73 EXTRACT(QUARTER FROM loan.LoanDate) 74 ORDER BY loan_count ASC 75 LIMIT 5; 42 76 }}} 43 77