Changes between Version 3 and Version 4 of izvestai


Ignore:
Timestamp:
01/29/25 17:28:53 (30 hours ago)
Author:
213209
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • izvestai

    v3 v4  
    11= Напредни извештаи од базата (SQL и складирани процедури)
    22
    3 == Извештај за откжани резервации по ресторан.
     3== Извештај за број на откжани, успешни резервации по ресторан
    44
    55{{{
    6 select
    7     count(rh.cancellation_reason),
     6SELECT
    87    au.first_name,
    98    au.last_name,
    109    au.membership_level,
    1110    au."role",
    12     rh.cancellation_reason,
    13     rh.restaurant_id
    14 from reservation_history rh 
    15 inner join app_user au on rh.customer_id = au.id
    16 where rh.cancellation_reason = 'Canceled by user'
    17 group by au.first_name,
    18     au.last_name,
    19     au.membership_level,
    20     au."role",
    21     rh.cancellation_reason,
    22     rh.restaurant_id
    23 order by rh.cancellation_reason
    24 }}}
     11    rh.restaurant_id,
     12   
     13    COUNT(CASE WHEN rh.cancellation_reason = 'Canceled by user' THEN 1 END) AS canceled_by_user_per_restaurant,
     14
     15    COUNT(CASE WHEN rh.cancellation_reason = '/' THEN 1 END) AS succesfull_by_user_per_restaurant,
     16   
     17    COUNT(CASE WHEN rh.cancellation_reason = 'Canceled by restaurant' THEN 1 END) AS canceled_by_restaurant,
     18
     19    COUNT(rh.cancellation_reason) AS total_cancellations_per_restaurant
     20
     21FROM reservation_history rh 
     22INNER JOIN app_user au ON rh.customer_id = au.id
     23
     24WHERE rh.cancellation_reason IS NOT NULL 
     25
     26GROUP BY au.first_name,
     27         au.last_name,
     28         au.membership_level,
     29         au."role",
     30         rh.restaurant_id
     31
     32ORDER BY canceled_by_user_per_restaurant DESC;}}}