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


Ignore:
Timestamp:
02/12/25 23:32:32 (10 days ago)
Author:
173067
Comment:

--

Legend:

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

    v4 v5  
    4848
    4949CREATE VIEW UserBookingExpenditureReport AS
    50 SELECT 
    51     u.userid, 
    52     u.name, 
    53     u.surname, 
    54     COUNT(b.bookingid) AS NumberOfBookings, 
     50SELECT
     51    u.userid,
     52    u.name,
     53    u.surname,
     54    COUNT(b.bookingid) AS NumberOfBookings,
    5555    SUM(b.total_cost) AS TotalExpenditure
    56 FROM 
    57     ApplicationUser u
    58 JOIN 
     56FROM
     57    application_user u
     58JOIN
    5959    Booking b ON u.userid = b.userid
    60 GROUP BY 
     60GROUP BY
    6161    u.userid, u.name, u.surname
    62 ORDER BY 
     62ORDER BY
    6363    TotalExpenditure DESC;
    6464
     
    8282    Booking b
    8383JOIN
    84     ApplicationUser u ON b.userid = u.userid
     84    application_user u ON b.userid = u.userid
    8585JOIN
    8686    Flight f ON b.flightid = f.flightid
     
    9595
    9696CREATE VIEW TopDestinationsWishlistReport AS
    97 SELECT 
    98     d.destinationid, 
    99     d.name AS DestinationName, 
    100     d.country, 
     97SELECT
     98    d.destinationid,
     99    d.name AS DestinationName,
     100    d.country,
    101101    COUNT(w.wishlistid) AS NumberOfWishlistEntries
    102 FROM 
     102FROM
    103103    Wishlist w
    104 JOIN 
    105     Destination d ON w.target_id = d.destinationid
    106 GROUP BY 
     104JOIN
     105    Destination d ON w.targetid = d.destinationid
     106GROUP BY
    107107    d.destinationid, d.name, d.country
    108 ORDER BY 
     108ORDER BY
    109109    NumberOfWishlistEntries DESC
    110110LIMIT 5;
     
    117117
    118118CREATE VIEW TopUsersByBookings AS
    119 SELECT 
    120     u.userid, 
    121     u.name, 
    122     u.surname, 
     119SELECT
     120    u.userid,
     121    u.name,
     122    u.surname,
    123123    COUNT(b.bookingid) AS NumberOfBookings
    124 FROM 
    125     ApplicationUser u
    126 JOIN 
     124FROM
     125    application_user u
     126JOIN
    127127    Booking b ON u.userid = b.userid
    128 GROUP BY 
     128GROUP BY
    129129    u.userid, u.name, u.surname
    130 ORDER BY 
     130ORDER BY
    131131    NumberOfBookings DESC;
    132132
     
    146146    Review r
    147147JOIN
    148     ApplicationUser u ON r.userid = u.userid
     148    application_user u ON r.userid = u.userid
    149149WHERE
    150150    r.target_id IN (SELECT FlightID FROM Flight)
     
    201201
    202202{{{
     203
     204CREATE VIEW TopMonhtlyReport AS
    203205WITH MonthlyBookings AS (
    204206    SELECT
     
    243245SELECT month, 'Airport' AS category, airport_name AS name, departures_count AS count FROM MonthlyAirports WHERE rank <= 3
    244246ORDER BY month, category, count DESC;
    245 }}}
     247
     248}}}