| 100 | |
| 101 | === Извештај за број на настани од одреден тип за секоја кетеринг фирма,просечен број на келнери што служеле,број на локации кај што биле одржувани и вкупен промет од тој тип настани за таа кетеринг фирма === |
| 102 | |
| 103 | {{{#!sql |
| 104 | |
| 105 | select ko.ime as ime_keterinzi, n.tip as tip_nastan, count(*) as broj_nastani_od_toj_tip, |
| 106 | round(avg(krn.kolicina)) as prosecno_kelneri, count(n.adresa) as broj_lokacii, |
| 107 | vkupen_promet_od_toj_tip_nastani |
| 108 | from nastani as n |
| 109 | |
| 110 | join ketering_rezervira_nastan krn on n.nastan_id = krn.nastan_id |
| 111 | join keterinzi as k on krn.korisnik_id = k.korisnik_id |
| 112 | join korisnici as ko on k.korisnik_id = ko.korisnik_id |
| 113 | join( |
| 114 | select ko.ime as ime_keterinzi, n.tip as tip_nastan, |
| 115 | sum(k.cena) as vkupen_promet_od_toj_tip_nastani from nastani as n |
| 116 | join ketering_rezervira_nastan krn on n.nastan_id = krn.nastan_id |
| 117 | join keterinzi as k on krn.korisnik_id = k.korisnik_id |
| 118 | join korisnici as ko on k.korisnik_id = ko.korisnik_id |
| 119 | group by 1 ,2 |
| 120 | order by ime_keterinzi |
| 121 | ) as promet_ketering on ko.ime = promet_ketering.ime_keterinzi and n.tip = promet_ketering.tip_nastan |
| 122 | |
| 123 | group by 1, 2, 6 |
| 124 | order by ime_keterinzi |
| 125 | }}} |
| 126 | |
| 127 | === Извештај за приходи за секој квартал од годината === |
| 128 | |
| 129 | {{{#!sql |
| 130 | select |
| 131 | ( |
| 132 | select sum(ke.cena + b.cena + f.cena) as vkupna_cena_nastan |
| 133 | |
| 134 | from nastani as n |
| 135 | |
| 136 | join bend_sviri_nastan bsn on n.nastan_id = bsn.nastan_id |
| 137 | join bendovi as b on bsn.korisnik_id = b.korisnik_id |
| 138 | join ketering_rezervira_nastan krn on n.nastan_id = krn.nastan_id |
| 139 | join fotograf_slika_nastan fsn on n.nastan_id = fsn.nastan_id |
| 140 | join fotografi as f on fsn.korisnik_id = f.korisnik_id |
| 141 | join keterinzi as ke on krn.korisnik_id = ke.korisnik_id |
| 142 | |
| 143 | where extract(month from n.datum) between 1 and 3 |
| 144 | |
| 145 | ) as prihod_prv_kvartal, |
| 146 | ( |
| 147 | select sum(ke.cena + b.cena + f.cena) as vkupna_cena_nastan from nastani as n |
| 148 | |
| 149 | join bend_sviri_nastan bsn on n.nastan_id = bsn.nastan_id |
| 150 | join bendovi as b on bsn.korisnik_id = b.korisnik_id |
| 151 | join ketering_rezervira_nastan krn on n.nastan_id = krn.nastan_id |
| 152 | join fotograf_slika_nastan fsn on n.nastan_id = fsn.nastan_id |
| 153 | join fotografi as f on fsn.korisnik_id = f.korisnik_id |
| 154 | join keterinzi as ke on krn.korisnik_id = ke.korisnik_id |
| 155 | |
| 156 | where extract(month from n.datum) between 4 and 6 |
| 157 | |
| 158 | ) as prihod_vtor_kvartal, |
| 159 | ( |
| 160 | select sum(ke.cena + b.cena + f.cena) as vkupna_cena_nastan from nastani as n |
| 161 | |
| 162 | join bend_sviri_nastan bsn on n.nastan_id = bsn.nastan_id |
| 163 | join bendovi as b on bsn.korisnik_id = b.korisnik_id |
| 164 | join ketering_rezervira_nastan krn on n.nastan_id = krn.nastan_id |
| 165 | join fotograf_slika_nastan fsn on n.nastan_id = fsn.nastan_id |
| 166 | join fotografi as f on fsn.korisnik_id = f.korisnik_id |
| 167 | join keterinzi as ke on krn.korisnik_id = ke.korisnik_id |
| 168 | |
| 169 | where extract(month from n.datum) between 7 and 9 |
| 170 | |
| 171 | ) as prihod_tret_kvartal, |
| 172 | ( |
| 173 | select sum(ke.cena + b.cena + f.cena) as vkupna_cena_nastan from nastani as n |
| 174 | |
| 175 | join bend_sviri_nastan bsn on n.nastan_id = bsn.nastan_id |
| 176 | join bendovi as b on bsn.korisnik_id = b.korisnik_id |
| 177 | join ketering_rezervira_nastan krn on n.nastan_id = krn.nastan_id |
| 178 | join fotograf_slika_nastan fsn on n.nastan_id = fsn.nastan_id |
| 179 | join fotografi as f on fsn.korisnik_id = f.korisnik_id |
| 180 | join keterinzi as ke on krn.korisnik_id = ke.korisnik_id |
| 181 | |
| 182 | where extract(month from n.datum) between 10 and 12 |
| 183 | |
| 184 | ) as prihod_cetvrt_kvartal |
| 185 | }}} |
| 186 | |