INSERT INTO tmp77lic (STREDISKO,PARTIE,PODNIK,LOMENI,PARTIECELA,NOMENKLA,NAZEVOSIVA,HMOTNOSTVN,PC,CISLODOKLA,CISLOFAKT)
select smesi.STREDISKO,smesi.PARTIE,smesi.PODNIK,smesi.LOMENI,smesi.PARTIECELA,smesi.NOMENKLA,smesi.NAZEVOSIVA,smesi.MNOZSTVI,smesi.PC,smesi.CISLODOKLA,"SM" from smesi
 where smesi.DATUM >= '2007-1-1'
 AND smesi.DATUM <= '2007-7-31'
 AND smesi.PODNIK = '0244'
 AND smesi.SMES="0"
 AND smesi.NOMENKLA IN (select nomenkla from tmp77lic3 order by nomenkla)
