SELECT a.cis_fak, a.cast_cel, x as kcs, a.mat_c_zu, a.znak_f, a.dat_odes, a.dat_pri, a.dat_spl, (2*a.cast_cel) as roz_cas, a.dan_cel, x as dan, (2*a.dan_cel) as roz_dan, a.vars_s, a.ico, a.zav as zavod, space (35) as nazev_org FROM fadod a INTO DBF c_fakt WHERE &QznF
SELECT a.cis_fak, a.cast_cel, SUM(b.kcs) as kcs, a.mat_c_zu, a.znak_f, a.dat_odes, a.dat_pri, a.dat_spl, ((2*a.cast_cel) - (SUM(b.kcs) + SUM(b.dan))) as roz_cas, a.dan_cel, SUM(b.dan) as dan, ((2*a.dan_cel) - SUM(b.dan)) as roz_dan, a.vars_s, a.ico, A.zav as zavod, space (35) as nazev_org FROM fadod a, lidod b INTO DBF c_fa WHERE a.cis_fak = b.cis_fak and &QznF GROUP BY 1
SELECT a.cis_fak, a.cast_cel, x as kcs, a.mat_c_zu, a.znak_f, a.dat_odes, a.dat_pri, a.dat_spl, a.cast_cel as roz_cas, a.dan_cel, x as dan, a.dan_cel as roz_dan, a.vars_s, a.ico, a.zav as zavod, space (35) as nazev_org FROM fadod a INTO DBF c_fakt WHERE &QznF
SELECT a.cis_fak, a.cast_cel, SUM(b.kcs) as kcs, a.mat_c_zu, a.znak_f, a.dat_odes, a.dat_pri, a.dat_spl, (a.cast_cel - (SUM(b.kcs) + SUM(b.dan))) as roz_cas, a.dan_cel, SUM(b.dan) as dan, (a.dan_cel - SUM(b.dan)) as roz_dan, a.vars_s, a.ico, a.zav as zavod, space (35) as nazev_org FROM fadod a, lidod b INTO DBF c_fa WHERE a.cis_fak = b.cis_fak and &QznF GROUP BY 1