165 | | select distinct(c2.id_cinema) as id,f2.id_film as film,sum(t1.price) as sum1 from tickets t1 |
166 | | join projections p2 on p2.id_projection=t1.id_projection |
167 | | join films f2 on f2.id_film = p2.id_film |
168 | | join cinema_plays_film cpf2 on cpf2.id_film=f2.id_film |
169 | | join cinemas c2 on c2.id_cinema=cpf2.id_cinema |
170 | | where t1.date_reserved between now()-interval'3 months' and now() |
171 | | group by c2.id_cinema,f2.id_film |
| 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 |
| 166 | join projection_is_played_in_room pipir on pipir.id_room=pr.id_room |
| 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 |
173 | | group by c.id_cinema |
174 | | ) as maks on maks.id1=c3.id_cinema |
175 | | join ( |
176 | | select distinct(c2.id_cinema) as id,f2.id_film as film,sum(t1.price) as sum2 from tickets t1 |
177 | | join projections p2 on p2.id_projection=t1.id_projection |
178 | | join films f2 on f2.id_film = p2.id_film |
179 | | join cinema_plays_film cpf2 on cpf2.id_film=f2.id_film |
180 | | join cinemas c2 on c2.id_cinema=cpf2.id_cinema |
181 | | where t1.date_reserved between now()-interval'3 months' and now() |
182 | | group by c2.id_cinema,f2.id_film |
183 | | ) as counts on counts.id=c3.id_cinema and counts.film=cpf3.id_film |
184 | | where counts.sum2=maks.sumMaks |
185 | | group by c3.id_cinema,cpf3.id_film |
186 | | order by c3.id_cinema |
| 173 | group by c.id_cinema,f.id_film |