Changes between Version 5 and Version 6 of Напредни извештаи од базата (SQL и складирани процедури)


Ignore:
Timestamp:
01/21/25 07:10:58 (30 hours ago)
Author:
201205
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Напредни извештаи од базата (SQL и складирани процедури)

    v5 v6  
    4646    coalesce((
    4747        select count(*)
    48         from Library l join LibraryBook lb on l.InventoryId = lb.InventoryId
     48        from Library l join ContainsLibraryBook lb on l.InventoryId = lb.InventoryId
    4949        where l.UserId=u.UserId
    5050    ), 0) as NumberOfBooksOwned,
     
    6565    extract(quarter from t.BorrowDate) as quarter,
    6666    b.Title, b.Author, count(*) as NumberOfTimesBorrowed
    67 from Transaction t join TransactionBook tb on t.TransactionId=tb.TransactionId join Book b on tb.BookId = b.BookId
     67from Transaction t join ExchangingBook eb on t.TransactionId=eb.TransactionId join Book b on eb.BookId = b.BookId
    6868group by
    6969    extract(year from t.BorrowDate),
     
    9191{{{
    9292select b.Title, b.Author, count(*) as TimesAddedToWishlist
    93 from WishlistBook wb join Book b on wb.BookId = b.BookId
     93from ContainsWishlistBook cwb join Book b on cwb.BookId = b.BookId
    9494group by b.BookId, b.Title, b.Author
    9595order by TimesAddedToWishlist desc
     
    104104with BookSwapCount as(
    105105        select b.Title, extract(year from t.BorrowDate) as SwapYear, count(tb.BookId) as SwapCount
    106         from Transaction t join TransactionBook tb on t.TransactionId=tb.TransactionId
    107                 join Book b on tb.BookId=b.BookId
     106        from Transaction t join ExchangingBook eb on t.TransactionId=eb.TransactionId
     107                join Book b on eb.BookId=b.BookId
    108108        group by b.title, extract(year from t.borrowdate)
    109109)
     
    127127        select au.Username, avg(r.Rating) as AverageRating
    128128        from AppUser au join Review r on au.UserId=r.ReceiverId
    129         where r.Date between '2025-01-01' and '2025-06-30'
     129        where r.ReviewDate between '2025-01-01' and '2025-06-30'
    130130        group by au.Username
    131131)