| 2 | |
| 3 | 1. Листа на вработени кои имаат направено барем едно отсуство, а не се пријавени во ниту еден оддел, а фирмата во која се вработени има барем еден оддел. |
| 4 | |
| 5 | {{{#!sql |
| 6 | select t1.v_id, t1.v_ime, t1.v_prezime, t1.v_telefon from vraboteni as t1 |
| 7 | join ( |
| 8 | select distinct v_id from otsustva as o |
| 9 | where exists( |
| 10 | select v_id, f_id from vraboteni as v |
| 11 | where not exists (select v_id from vraboten_vo_oddel as vvo where v_id=v.v_id) |
| 12 | and exists (select distinct f_id from oddeli as o2 where f_id=v.f_id) |
| 13 | and o.v_id=v.v_id) |
| 14 | ) as t2 on t1.v_id=t2.v_id |
| 15 | where t1.v_aktiven=1 and t1.f_id=1 |
| 16 | }}} |
| 17 | |
| 18 | 2. Листа на фирми со обем на внесени податоци(вкупно отсуства по сите вработени). Овој извештај служи за администраторот да има евиденција која фирма има и може да ги шире податоците. |
| 19 | |
| 20 | {{{#!sql |
| 21 | Zoran sent 7 May at 13:42 |
| 22 | select t1.f_id, t1.f_ime, t1.f_grad, |
| 23 | (case when t2.vkupno_otsustva is null then 0 else t2.vkupno_otsustva end) * |
| 24 | (case when koef_vraboteni is null then 1 else koef_vraboteni end) * koef_oddeli as count_data |
| 25 | from firmi as t1 |
| 26 | left join( |
| 27 | select f.f_id, sum(1) as vkupno_otsustva from firmi as f |
| 28 | join vraboteni as v on v.f_id=f.f_id |
| 29 | join otsustva as o on o.v_id=v.v_id |
| 30 | group by f.f_id) as t2 on t2.f_id=t1.f_id |
| 31 | left join ( |
| 32 | select f_id, (case when sum(1)<50 then 1 else (case when sum(1)<100 then 2 else 3 end) end) |
| 33 | as koef_vraboteni from vraboteni as v |
| 34 | group by f_id) as t3 on t3.f_id=t1.f_id |
| 35 | left join ( |
| 36 | select f.f_id, (case when sum(1) is null then 1 else sum(1) end) as koef_oddeli from firmi as f |
| 37 | left join oddeli as o on o.f_id=f.f_id |
| 38 | group by f.f_id) as t4 on t4.f_id=t1.f_id |
| 39 | order by count_data desc |
| 40 | }}} |