Changes between Version 12 and Version 13 of AdvancedReports


Ignore:
Timestamp:
01/06/23 04:22:18 (2 years ago)
Author:
201094
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v12 v13  
    162162join tickets t on t.id_projection=p.id_projection and t.date_reserved between now()-interval'3 months' and now()
    163163join (
    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 
     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 
    172172) as sum_cena on sum_cena.id=c.id_cinema
    173 group by c.id_cinema,f.id_film
    174 
     173group by c.id_cinema,f.id_film
    175174}}}
    176175=== Извештај за секој клиент, за секое кино, колку карти има купено во секое кино, колку пари има потрошено во секое кино, и колку кодови за попуст имаат искористено во секое кино ===
     
    179178select c.id_customer, c2.id_cinema ,
    180179coalesce((
    181 select count(distinct t1.id_ticket) from tickets t1
    182 join projections p on p.id_projection=t1.id_projection
    183 join projection_is_played_in_room pipir on pipir.id_projection=p.id_projection
    184 join projection_rooms pr on pr.id_room=pipir.id_room
    185 join cinemas cin on cin.id_cinema=pr.id_cinema
    186 where cin.id_cinema=c2.id_cinema and t1.id_customer=c.id_customer)
     180        select count(distinct t1.id_ticket) from tickets t1
     181        join projections p on p.id_projection=t1.id_projection
     182        join projection_is_played_in_room pipir on pipir.id_projection=p.id_projection
     183        join projection_rooms pr on pr.id_room=pipir.id_room
     184        join cinemas cin on cin.id_cinema=pr.id_cinema
     185        where cin.id_cinema=c2.id_cinema and t1.id_customer=c.id_customer)
    187186,0),
    188187coalesce((
    189 select sum(t1.price) from tickets t1
    190 join projections p on p.id_projection=t1.id_projection
    191 join projection_is_played_in_room pipir on pipir.id_projection=p.id_projection
    192 join projection_rooms pr on pr.id_room=pipir.id_room
    193 join cinemas cin on cin.id_cinema=pr.id_cinema
    194 where cin.id_cinema=c2.id_cinema and t1.id_customer=c.id_customer)
     188        select sum(t1.price) from tickets t1
     189        join projections p on p.id_projection=t1.id_projection
     190        join projection_is_played_in_room pipir on pipir.id_projection=p.id_projection
     191        join projection_rooms pr on pr.id_room=pipir.id_room
     192        join cinemas cin on cin.id_cinema=pr.id_cinema
     193        where cin.id_cinema=c2.id_cinema and t1.id_customer=c.id_customer)
    195194,0),
    196195coalesce((
    197 select count(distinct d.id_discount) from discounts d
    198 join tickets t1  on t1.id_discount = d.id_discount
    199 join projections p on p.id_projection=t1.id_projection
    200 join projection_is_played_in_room pipir on pipir.id_projection=p.id_projection
    201 join projection_rooms pr on pr.id_room=pipir.id_room
    202 join cinemas cin on cin.id_cinema=pr.id_cinema
    203 where cin.id_cinema=c2.id_cinema and t1.id_customer=c.id_customer
     196        select count(distinct d.id_discount) from discounts d
     197        join tickets t1  on t1.id_discount = d.id_discount
     198        join projections p on p.id_projection=t1.id_projection
     199        join projection_is_played_in_room pipir on pipir.id_projection=p.id_projection
     200        join projection_rooms pr on pr.id_room=pipir.id_room
     201        join cinemas cin on cin.id_cinema=pr.id_cinema
     202        where cin.id_cinema=c2.id_cinema and t1.id_customer=c.id_customer
    204203),0)
    205204from customers c
     
    212211group by c.id_customer,c2.id_cinema
    213212order by c.id_customer
     213
    214214}}}
    215215
     
    218218select f.id_film,
    219219coalesce((
    220 select count(distinct t.id_ticket) from tickets t
    221 left join projections p on p.id_projection=t.id_projection
    222 left join films f1 on f1.id_film=p.id_film
    223 where f.id_film=f1.id_film
    224 ),0),
    225 coalesce((
    226 select sum(t.price) from tickets t
    227 left join projections p on p.id_projection=t.id_projection
    228 left join films f1 on f1.id_film=p.id_film
    229 where f.id_film=f1.id_film
    230 ),0),
    231 coalesce((
    232 select count(distinct c.id_customer) from customers c
    233 left join tickets t2 on t2.id_customer=c.id_customer
    234 left join projections p on p.id_projection=t2.id_projection
    235 left join films f1 on f1.id_film=p.id_film
    236 where f.id_film=f1.id_film
    237 ),0),
    238 coalesce((
    239 select count(crf.rating) from customer_rates_film crf
    240 left join films f2 on f2.id_film=crf.id_film
    241 where f2.id_film=f.id_film
     220        select count(distinct t.id_ticket) from tickets t
     221        left join projections p on p.id_projection=t.id_projection
     222        left join films f1 on f1.id_film=p.id_film
     223        where f.id_film=f1.id_film
     224),0),
     225coalesce((
     226        select sum(t.price) from tickets t
     227        left join projections p on p.id_projection=t.id_projection
     228        left join films f1 on f1.id_film=p.id_film
     229        where f.id_film=f1.id_film
     230),0),
     231coalesce((
     232        select count(distinct c.id_customer) from customers c
     233        left join tickets t2 on t2.id_customer=c.id_customer
     234        left join projections p on p.id_projection=t2.id_projection
     235        left join films f1 on f1.id_film=p.id_film
     236        where f.id_film=f1.id_film
     237),0),
     238coalesce((
     239        select count(crf.rating) from customer_rates_film crf
     240        left join films f2 on f2.id_film=crf.id_film
     241        where f2.id_film=f.id_film
    242242),0)
    243243from films f
     
    248248select c.id_cinema,
    249249coalesce((
    250 select count(distinct w.id_worker) from workers w
    251 left join cinemas c1 on c1.id_cinema=w.id_cinema
    252 where c1.id_cinema=c.id_cinema
    253 ),0),
    254 coalesce((
    255 select sum(s.sum) from salaries s
    256 left join workers w2 on s.id_worker=w2.id_worker
    257 left join cinemas c1 on c1.id_cinema=w2.id_cinema
    258 where c1.id_cinema=c.id_cinema and s.date_to is null
     250        select count(distinct w.id_worker) from workers w
     251        left join cinemas c1 on c1.id_cinema=w.id_cinema
     252        where c1.id_cinema=c.id_cinema
     253),0),
     254coalesce((
     255        select sum(s.sum) from salaries s
     256        left join workers w2 on s.id_worker=w2.id_worker
     257        left join cinemas c1 on c1.id_cinema=w2.id_cinema
     258        where c1.id_cinema=c.id_cinema and s.date_to is null
    259259),0)
    260 from cinemas c
     260from cinemas c  
    261261}}}
    262262