Changes between Version 11 and Version 12 of AdvancedReports


Ignore:
Timestamp:
01/06/23 04:15:52 (23 months ago)
Author:
201094
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v11 v12  
    153153{{{#!sql
    154154
    155 select c3.id_cinema,cpf3.id_film from cinemas c3
    156 join cinema_plays_film cpf3 on cpf3.id_cinema=c3.id_cinema
    157 join (
    158 select c.id_cinema as id1,max(sum_cena.sum1) as sumMaks
     155select c.id_cinema as id1,max(sum_cena.sum1) as sumMaks,f.id_film, f."name"
    159156from cinemas c
     157join projection_rooms pr on pr.id_cinema=c.id_cinema
     158join projection_is_played_in_room pipir on pipir.id_room=pr.id_room
     159join projections p on p.id_projection = pipir.id_projection
    160160join cinema_plays_film cpf on cpf.id_cinema=c.id_cinema
    161 join films f on f.id_film=cpf.id_film
    162 join projections p on p.id_film=f.id_film
     161join films f on f.id_film=cpf.id_film and f.id_film=p.id_film
    163162join tickets t on t.id_projection=p.id_projection and t.date_reserved between now()-interval'3 months' and now()
    164163join (
    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
     164select c.id_cinema as id,f.id_film as film,sum(t.price) as sum1  from cinemas c
     165join projection_rooms pr on pr.id_cinema=c.id_cinema
     166join projection_is_played_in_room pipir on pipir.id_room=pr.id_room
     167join projections p on p.id_projection=pipir.id_projection
     168join films f on f.id_film=p.id_film
     169join tickets t on t.id_projection=p.id_projection
     170where t.date_reserved between now()-interval'3 months' and now()
     171group by c.id_cinema,f.id_film 
    172172) as sum_cena on sum_cena.id=c.id_cinema
    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
     173group by c.id_cinema,f.id_film
    187174
    188175}}}