155 | | select c.id_cinema as id1,max(sum_cena.sum1) as sumMaks,f.id_film, f."name" |
156 | | from cinemas c |
157 | | join projection_rooms pr on pr.id_cinema=c.id_cinema |
158 | | join projection_is_played_in_room pipir on pipir.id_room=pr.id_room |
159 | | join projections p on p.id_projection = pipir.id_projection |
160 | | join cinema_plays_film cpf on cpf.id_cinema=c.id_cinema |
161 | | join films f on f.id_film=cpf.id_film and f.id_film=p.id_film |
162 | | join tickets t on t.id_projection=p.id_projection and t.date_reserved between now()-interval'3 months' and now() |
163 | | join ( |
164 | | select c.id_cinema as id,f.id_film as film,sum(t.price) as sum1 from cinemas c |
165 | | join projection_rooms pr on pr.id_cinema=c.id_cinema |
| 155 | select c2.id_cinema,maks.sumMaks,sum_3.film3 from cinemas c2 |
| 156 | join projection_rooms pr2 on pr2.id_cinema=c2.id_cinema |
| 157 | join projection_is_played_in_room pipir2 on pipir2.id_room=pr2.id_room |
| 158 | join projections p2 on p2.id_projection = pipir2.id_projection |
| 159 | join films f2 on f2.id_film=p2.id_film |
| 160 | join( |
| 161 | select c.id_cinema as id1,max(sum_cena.sum1) as sumMaks |
| 162 | from cinemas c |
| 163 | join projection_rooms pr on pr.id_cinema=c.id_cinema |
167 | | join projections p on p.id_projection=pipir.id_projection |
168 | | join films f on f.id_film=p.id_film |
169 | | join tickets t on t.id_projection=p.id_projection |
170 | | where t.date_reserved between now()-interval'3 months' and now() |
171 | | group by c.id_cinema,f.id_film |
172 | | ) as sum_cena on sum_cena.id=c.id_cinema |
173 | | group by c.id_cinema,f.id_film |
| 165 | join projections p on p.id_projection = pipir.id_projection |
| 166 | join cinema_plays_film cpf on cpf.id_cinema=c.id_cinema |
| 167 | join films f on f.id_film=p.id_film |
| 168 | join tickets t on t.id_projection=p.id_projection and t.date_reserved between now()-interval'3 months' and now() |
| 169 | join ( |
| 170 | select c1.id_cinema as id,f1.id_film as film,sum(t1.price) as sum1 from cinemas c1 |
| 171 | join projection_rooms pr1 on pr1.id_cinema=c1.id_cinema |
| 172 | join projection_is_played_in_room pipir1 on pipir1.id_room=pr1.id_room |
| 173 | join projections p1 on p1.id_projection=pipir1.id_projection |
| 174 | join films f1 on f1.id_film=p1.id_film |
| 175 | join tickets t1 on t1.id_projection=p1.id_projection |
| 176 | where t1.date_reserved between now()-interval'3 months' and now() |
| 177 | group by c1.id_cinema,f1.id_film |
| 178 | ) as sum_cena on sum_cena.id=c.id_cinema and sum_cena.film=f.id_film |
| 179 | group by c.id_cinema |
| 180 | ) as maks on maks.id1=c2.id_cinema |
| 181 | join( |
| 182 | select c3.id_cinema as id3,f3.id_film as film3,sum(t3.price) as sum3 from cinemas c3 |
| 183 | join projection_rooms pr3 on pr3.id_cinema=c3.id_cinema |
| 184 | join projection_is_played_in_room pipir3 on pipir3.id_room=pr3.id_room |
| 185 | join projections p3 on p3.id_projection=pipir3.id_projection |
| 186 | join films f3 on f3.id_film=p3.id_film |
| 187 | join tickets t3 on t3.id_projection=p3.id_projection |
| 188 | where t3.date_reserved between now()-interval'3 months' and now() |
| 189 | group by c3.id_cinema,f3.id_film |
| 190 | ) as sum_3 on sum_3.id3=c2.id_cinema and sum_3.film3=f2.id_film and sum_3.sum3=maks.sumMaks |
| 191 | group by c2.id_cinema,maks.sumMaks,sum_3.film3 |