| 147 | {{{#!sql |
| 148 | select distinct a.auditorium_name , q4.god as godina,a.auditorium_capacity,vkupna_brojka.vkupno,q4.broj_odrzani_filmovi as broj_odrzani_filmovi |
| 149 | from |
| 150 | ( |
| 151 | select * from |
| 152 | ( |
| 153 | select q1.godina as god , max(q1.broj_odrzani_filmovi) as maksimum from |
| 154 | ( |
| 155 | select extract(year from r.reservation_date)as godina ,r.reservation_id as rez ,count(r.projection_id) as broj_odrzani_filmovi |
| 156 | from reservation as r |
| 157 | join seat as s2 on r.seat_id=s2.seat_id |
| 158 | join auditorium as a2 on s2.auditorium_id=a2.auditorium_id |
| 159 | join movieprojection as mp1 on r.projection_id=mp1.projection_id |
| 160 | group by 1,2 |
| 161 | )q1 |
| 162 | group by godina |
| 163 | |
| 164 | )q2 |
| 165 | join |
| 166 | ( |
| 167 | select extract (year from r.reservation_date)as godina , r.reservation_id as rez,count(r.projection_id) as broj_odrzani_filmovi |
| 168 | from reservation as r |
| 169 | join seat as s3 on r.seat_id=s3.seat_id |
| 170 | join auditorium as a3 on s3.auditorium_id=a3.auditorium_id |
| 171 | join movieprojection as mp2 on r.projection_id=mp2.projection_id |
| 172 | group by 1,2 |
| 173 | )q3 |
| 174 | on q2.god=q3.godina and q2.maksimum=q3.broj_odrzani_filmovi |
| 175 | |
| 176 | ) q4 |