| | 34 | }}} |
| | 35 | }}} |
| | 36 | == Извештај за купувач според тромесечие, купени карти и придонес |
| | 37 | |
| | 38 | {{{#!div style="font-size: 90%" |
| | 39 | {{{#!sql |
| | 40 | select distinct u.user_name,u.user_surname, |
| | 41 | case when tabela.quarter=1 then tabela.broj_kupeni else 0 end as prv_kvartal_kupeni, |
| | 42 | case when tabela.quarter=2 then tabela.broj_kupeni else 0 end as vtor_kvartal_kupeni, |
| | 43 | case when tabela.quarter=3 then tabela.broj_kupeni else 0 end as tret_kvartal_kupeni, |
| | 44 | case when tabela.quarter=4 then tabela.broj_kupeni else 0 end as cetvrt_kvartal_kupeni, |
| | 45 | ------------------------------------------------------------------------------- |
| | 46 | case when tabela.quarter=1 then tabela.suma else 0 end as prv_kvartal_suma, |
| | 47 | case when tabela.quarter=2 then tabela.suma else 0 end as vtor_kvartal_suma, |
| | 48 | case when tabela.quarter=3 then tabela.suma else 0 end as tret_kvartal_suma, |
| | 49 | case when tabela.quarter=4 then tabela.suma else 0 end as cetvrt_kvartal_suma |
| | 50 | |
| | 51 | |
| | 52 | from reservation as r |
| | 53 | join client as c on c.user_id = r.user_id |
| | 54 | join movieprojection as mp on mp.projection_id = r.projection_id |
| | 55 | join users as u on u.user_id = c.user_id |
| | 56 | join( |
| | 57 | select distinct c2.user_id,extract(quarter from r2.reservation_date) as quarter,sum(mp.projection_price) as suma, |
| | 58 | count(r2.reservation_id) as broj_kupeni |
| | 59 | from reservation as r2 |
| | 60 | join movieprojection as mp on mp.projection_id = r2.projection_id |
| | 61 | join client as c2 on c2.user_id = r2.user_id |
| | 62 | group by 1,2 |
| | 63 | ) as tabela on c.user_id = tabela.user_id |
| 112 | | {{{#!div style="font-size: 90%" |
| 113 | | {{{#!sql |
| 114 | | select distinct u.user_name,u.user_surname, |
| 115 | | case when tabela.quarter=1 then tabela.broj_kupeni else 0 end as prv_kvartal_kupeni, |
| 116 | | case when tabela.quarter=2 then tabela.broj_kupeni else 0 end as vtor_kvartal_kupeni, |
| 117 | | case when tabela.quarter=3 then tabela.broj_kupeni else 0 end as tret_kvartal_kupeni, |
| 118 | | case when tabela.quarter=4 then tabela.broj_kupeni else 0 end as cetvrt_kvartal_kupeni, |
| 119 | | ------------------------------------------------------------------------------- |
| 120 | | case when tabela.quarter=1 then tabela.suma else 0 end as prv_kvartal_suma, |
| 121 | | case when tabela.quarter=2 then tabela.suma else 0 end as vtor_kvartal_suma, |
| 122 | | case when tabela.quarter=3 then tabela.suma else 0 end as tret_kvartal_suma, |
| 123 | | case when tabela.quarter=4 then tabela.suma else 0 end as cetvrt_kvartal_suma |
| 124 | | |
| 125 | | |
| 126 | | from reservation as r |
| 127 | | join client as c on c.user_id = r.user_id |
| 128 | | join movieprojection as mp on mp.projection_id = r.projection_id |
| 129 | | join users as u on u.user_id = c.user_id |
| 130 | | join( |
| 131 | | select distinct c2.user_id,extract(quarter from r2.reservation_date) as quarter,sum(mp.projection_price) as suma, |
| 132 | | count(r2.reservation_id) as broj_kupeni |
| 133 | | from reservation as r2 |
| 134 | | join movieprojection as mp on mp.projection_id = r2.projection_id |
| 135 | | join client as c2 on c2.user_id = r2.user_id |
| 136 | | group by 1,2 |
| 137 | | ) as tabela on c.user_id = tabela.user_id |
| 138 | | }}} |
| 139 | | }}} |