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 | |
| 21 | FROM reservation_history rh |
| 22 | INNER JOIN app_user au ON rh.customer_id = au.id |
| 23 | |
| 24 | WHERE rh.cancellation_reason IS NOT NULL |
| 25 | |
| 26 | GROUP BY au.first_name, |
| 27 | au.last_name, |
| 28 | au.membership_level, |
| 29 | au."role", |
| 30 | rh.restaurant_id |
| 31 | |
| 32 | ORDER BY canceled_by_user_per_restaurant DESC;}}} |