| | 1 | = Напредни извештаи од базата (SQL и складирани процедури) = |
| | 2 | |
| | 3 | === Извештај за сите кина, на месечно ниво, колку карти се пордадени и вкупниот профит во предходната година === |
| | 4 | {{{#!sql |
| | 5 | select c.id_cinema,c.name, |
| | 6 | coalesce(prv_mesec.karti, 0) as prvi_mesec, |
| | 7 | coalesce(vtor_mesec.karti, 0) as vtori_mesec, |
| | 8 | coalesce(tret_mesec.karti, 0) as tretti_mesec, |
| | 9 | coalesce(cetvrt_mesec.karti,0) as cetvrti_mesec, |
| | 10 | coalesce(pet_mesec.karti,0) as petti_mesec, |
| | 11 | coalesce(sest_mesec.karti,0) as sesti_mesec, |
| | 12 | coalesce(sedum_mesec.karti, 0) as sedmi_mesec, |
| | 13 | coalesce(osum_mesec.karti,0) as osmi_mesec, |
| | 14 | coalesce(devet_mesec.karti,0) as devetti_mesec, |
| | 15 | coalesce(deset_mesec.karti, 0) as desetti_mesec, |
| | 16 | coalesce(edinaeset_mesec.karti11,0) as edinaesti_mesec, |
| | 17 | coalesce(dvanaeset_mesec.karti,0) as dvanaesti_mesec, |
| | 18 | sum(t.price) as vkupen_promet |
| | 19 | from cinemas c |
| | 20 | join projection_rooms pr on pr.id_cinema=c.id_cinema |
| | 21 | join projection_is_played_in_room pipir on pipir.id_room =pr.id_room |
| | 22 | join projections p on p.id_projection = pipir.id_projection |
| | 23 | join tickets t on t.id_projection=p.id_projection |
| | 24 | left join ( |
| | 25 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 26 | join projections p1 on t3.id_projection = p1.id_projection |
| | 27 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 28 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 29 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 30 | where extract(month from t3.date_reserved)=1 |
| | 31 | group by c2.id_cinema |
| | 32 | |
| | 33 | ) as prv_mesec on prv_mesec.id=c.id_cinema |
| | 34 | left join ( |
| | 35 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 36 | join projections p1 on t3.id_projection = p1.id_projection |
| | 37 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 38 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 39 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 40 | where extract(month from t3.date_reserved)=2 |
| | 41 | group by c2.id_cinema |
| | 42 | |
| | 43 | ) as vtor_mesec on vtor_mesec.id=c.id_cinema |
| | 44 | left join ( |
| | 45 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 46 | join projections p1 on t3.id_projection = p1.id_projection |
| | 47 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 48 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 49 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 50 | where extract(month from t3.date_reserved)=3 |
| | 51 | group by c2.id_cinema |
| | 52 | |
| | 53 | ) as tret_mesec on tret_mesec.id=c.id_cinema |
| | 54 | left join ( |
| | 55 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 56 | join projections p1 on t3.id_projection = p1.id_projection |
| | 57 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 58 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 59 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 60 | where extract(month from t3.date_reserved)=4 |
| | 61 | group by c2.id_cinema |
| | 62 | |
| | 63 | ) as cetvrt_mesec on cetvrt_mesec.id=c.id_cinema |
| | 64 | left join ( |
| | 65 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 66 | join projections p1 on t3.id_projection = p1.id_projection |
| | 67 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 68 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 69 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 70 | where extract(month from t3.date_reserved)=5 |
| | 71 | group by c2.id_cinema |
| | 72 | |
| | 73 | ) as pet_mesec on pet_mesec.id=c.id_cinema |
| | 74 | left join ( |
| | 75 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 76 | join projections p1 on t3.id_projection = p1.id_projection |
| | 77 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 78 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 79 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 80 | where extract(month from t3.date_reserved)=6 |
| | 81 | group by c2.id_cinema |
| | 82 | |
| | 83 | ) as sest_mesec on sest_mesec.id=c.id_cinema |
| | 84 | left join ( |
| | 85 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 86 | join projections p1 on t3.id_projection = p1.id_projection |
| | 87 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 88 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 89 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 90 | where extract(month from t3.date_reserved)=7 |
| | 91 | group by c2.id_cinema |
| | 92 | |
| | 93 | ) as sedum_mesec on sedum_mesec.id=c.id_cinema |
| | 94 | left join ( |
| | 95 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 96 | join projections p1 on t3.id_projection = p1.id_projection |
| | 97 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 98 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 99 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 100 | where extract(month from t3.date_reserved)=8 |
| | 101 | group by c2.id_cinema |
| | 102 | |
| | 103 | ) as osum_mesec on osum_mesec.id=c.id_cinema |
| | 104 | left join ( |
| | 105 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 106 | join projections p1 on t3.id_projection = p1.id_projection |
| | 107 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 108 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 109 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 110 | where extract(month from t3.date_reserved)=9 |
| | 111 | group by c2.id_cinema |
| | 112 | |
| | 113 | ) as devet_mesec on devet_mesec.id=c.id_cinema |
| | 114 | left join ( |
| | 115 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 116 | join projections p1 on t3.id_projection = p1.id_projection |
| | 117 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 118 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 119 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 120 | where extract(month from t3.date_reserved)=10 |
| | 121 | group by c2.id_cinema |
| | 122 | |
| | 123 | ) as deset_mesec on deset_mesec.id=c.id_cinema |
| | 124 | left join ( |
| | 125 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti11,sum(t3.price) as sum1 from tickets t3 |
| | 126 | join projections p1 on t3.id_projection = p1.id_projection |
| | 127 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 128 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 129 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 130 | where extract(month from t3.date_reserved)=11 |
| | 131 | group by c2.id_cinema |
| | 132 | |
| | 133 | ) as edinaeset_mesec on edinaeset_mesec.id=c.id_cinema |
| | 134 | left join ( |
| | 135 | select distinct(c2.id_cinema) as id,count(distinct t3.id_ticket) as karti,sum(t3.price) as sum1 from tickets t3 |
| | 136 | join projections p1 on t3.id_projection = p1.id_projection |
| | 137 | join projection_is_played_in_room pipir2 on pipir2.id_projection=p1.id_projection |
| | 138 | join projection_rooms pr2 on pr2.id_room=pipir2.id_room |
| | 139 | join cinemas c2 on c2.id_cinema=pr2.id_cinema |
| | 140 | where extract(month from t3.date_reserved)=12 |
| | 141 | group by c2.id_cinema |
| | 142 | |
| | 143 | ) as dvanaeset_mesec on dvanaeset_mesec.id=c.id_cinema |
| | 144 | where extract(year from t.date_reserved)=extract(year from now()-interval'1 year') |
| | 145 | group by c.id_cinema,prv_mesec.karti,vtor_mesec.karti,tret_mesec.karti,cetvrt_mesec.karti, |
| | 146 | pet_mesec.karti,sest_mesec.karti,sedum_mesec.karti,osum_mesec.karti,devet_mesec.karti,deset_mesec.karti, |
| | 147 | edinaeset_mesec.karti11,dvanaeset_mesec.karti |
| | 148 | order by c.id_cinema |
| | 149 | |
| | 150 | }}} |
| | 151 | === Извештај за успешноста на еден доставувач. Се прикажуваат информации за доставувачот, број на нарачки што ги доставил и вкупна вредност на сите нарачки што ги доставил === |
| | 152 | |
| | 153 | |
| | 154 | === Извештај за сеуште недоставените нарачки, од кој дел во која количина ни треба, колку од тој дел имаме во магацин и дали е потребно да се нарачаат за во магацин === |
| | 155 | ===== Се пресметуваат колку количина од деловите имало во завршените нарачки во последните 3 месеци и се додава моменталната количина во нарачки што се уште не |
| | 156 | === Извештај за сите сервиси,број на критики кои ги добиле и нивниот просечен рејтинг === |
| | 157 | |