Pom17
Z Prirucky
select A.os_cislo, A.prijmeni, A.jmeno, B.cislo_pom, (select zust_minul from dovolena D1 where D1.os_cislo = B.os_cislo and D1.cislo_pom = B.cislo_pom and datum = '2016-01-01') as min_201601, (select zust_minul from dovolena D2 where D2.os_cislo = B.os_cislo and D2.cislo_pom = B.cislo_pom and datum = '2016-11-01') as min_201611, ( (select zust_minul from dovolena D1 where D1.os_cislo = B.os_cislo and D1.cislo_pom = B.cislo_pom and datum = '2016-01-01') - (select zust_minul from dovolena D2 where D2.os_cislo = B.os_cislo and D2.cislo_pom = B.cislo_pom and datum = '2016-11-01') ) as rozd_min, (select sum (dny) from pichacky P where P.os_cislo = B.os_cislo and P.cislo_pom = B.cislo_pom and P.kod in (select kod from ciselnik where ind_abs = 1) and P.datum >= '2016-01-01' and P.datum <= '2016-10-01') as cerp_btto, (select cerpana from dovolena D3 where D3.os_cislo = B.os_cislo and D3.cislo_pom = B.cislo_pom and datum = '2016-11-01') as cerp_dov, ( (select sum (dny) from pichacky P where P.os_cislo = B.os_cislo and P.cislo_pom = B.cislo_pom and P.kod in (select kod from ciselnik where ind_abs = 1) and P.datum >= '2016-01-01' and P.datum <= '2016-10-01') - (select cerpana from dovolena D3 where D3.os_cislo = B.os_cislo and D3.cislo_pom = B.cislo_pom and datum = '2016-11-01') ) as rozd_cerp from pracovnici A, prac_pom B where A.os_cislo = B.os_cislo