| 118 | |
| 119 | == Извештај за преглед на популарен тип на соба |
| 120 | |
| 121 | {{{#!sql |
| 122 | select distinct r.room_type, |
| 123 | ( |
| 124 | select count(r2.reservation_id) |
| 125 | where r.room_type = 'Single' |
| 126 | ) as single_room_reservation, |
| 127 | ( |
| 128 | select count(r2.reservation_id) |
| 129 | where r.room_type = 'Double' |
| 130 | )as double_room_reservation |
| 131 | from rooms r |
| 132 | join reservation r2 |
| 133 | on r.room_id = r2.room_id |
| 134 | group by 1; |
| 135 | }}} |
| 136 | |
| 137 | == Преглед на вкупниот број резервации кои ги има направено секој од корисниците |
| 138 | |
| 139 | {{{#!sql |
| 140 | select ut.full_name , sum(gmr.reservation_id) as number_reservations |
| 141 | from user_table ut |
| 142 | join guests g |
| 143 | on ut.user_id = g.user_id |
| 144 | join guests_make_reservation gmr |
| 145 | on g.user_id = gmr.user_id |
| 146 | join reservation r |
| 147 | on gmr.reservation_id = r.reservation_id |
| 148 | group by 1; |
| 149 | }}} |
| 150 | |
| 151 | == Број на соби во секоја вила |
| 152 | |
| 153 | {{{#!sql |
| 154 | select v.name as villa_name , |
| 155 | count(r.room_id) as number_of_rooms |
| 156 | from villa v |
| 157 | join rooms r on |
| 158 | r.villa_id = v.villa_id |
| 159 | group by villa_name |
| 160 | order by villa_name |
| 161 | }}} |