Changes between Version 3 and Version 4 of Advanced database reports (SQL and Stored procedures)
- Timestamp:
- 12/21/22 16:54:12 (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Advanced database reports (SQL and Stored procedures)
v3 v4 17 17 == Вкупен број на настани во последните 6 месеци, вкупен број на гости на настаните, просечна цена на настан по гостин и вкупен промет од сите настани 18 18 19 {{{#!sql 19 20 select count(e.event_id) as num_events, 20 21 sum(e.number_of_interested_guests) as total_guests, … … 28 29 join events e on 29 30 rfe.event_id = e.event_id 31 }}} 30 32 31 33 == Вкупен број на активности во последната година, вкупен број на гости на активностите, просечна цена на активност по гостин и вкупен промет од сите активности 32 34 35 {{{#!sql 36 select count(a.activity_id) as num_activities, 37 sum(a.number_of_interested_guests) as total_guests, 38 avg(a.price) as avg_price, 39 sum(a.price * a.number_of_interested_guests) as sales 40 from reservation_for_activity rfa 41 join reservation r on 42 rfa.reservation_id = r.reservation_id 43 and 44 (start_date between now() - interval '1 year' and now()) 45 join activities a on 46 rfa.activity_id = a.activity_id 47 }}} 48 33 49 == Просечна плата на секој тип на вработени во Вила Дихово 50 51 {{{#!sql 52 select 53 ( 54 select count(w.user_id) 55 from waiter w 56 )as waiters_in_villa_dihovo, 57 ( 58 select avg(w.salary) 59 from waiter w 60 )as average_salary_waiter, 61 ( 62 select count(r.user_id) 63 from receptionist r 64 )as receptionists_in_villa_dihovo, 65 ( 66 select avg(r.salary) 67 from receptionist r 68 )as average_salary_receptionist, 69 ( 70 select count(c.user_id) 71 from chef c 72 ) as chefs_in_villa_dihovo, 73 ( 74 select avg(c.salary) 75 from chef c 76 )as average_salary_chef 77 78 from user_table ut 79 group by 1,2,3; 80 }}} 34 81 35 82 == Број на соби во секоја вила 36 83 84 {{{#!sql 85 select v.name as villa_name , 86 count(r.room_id) as number_of_rooms 87 from villa v 88 join rooms r on 89 r.villa_id = v.villa_id 90 group by villa_name 91 order by villa_name 92 }}} 93 37 94 == Нарачки за храна кој ги има направено еден корисник и вкупна сума на плаќање 95 96 {{{#!sql 97 select pm.user_id, 98 ut.full_name, 99 count(ut.full_name) as broj_naracki_hrana, 100 sum(rfpm.quantity * m.price) as total_sum 101 from prepared_meal pm 102 join user_table ut on 103 pm.user_id = ut.user_id 104 join meal m on 105 pm.meal_id = m.meal_id 106 join reservation_for_prepared_meal rfpm on 107 rfpm.prepared_meal_id = pm.prepared_meal_id 108 join reservation r on 109 rfpm.reservation_id = r.reservation_id 110 group by 1,2 111 }}}