SELECT Obj_polozky.id_cnk,SUM(Obj_polozky.cena_summn) AS CENA,cenik.nazev_zbozi,COUNT(Obj_polozky.id_dobj) AS POCET_OBJ,SUM(Obj_polozky.mnozstvi) AS MNOZ,MAX(Obj_header.datum) AS POSLEDNI,cenik.kod_zbozi,Sumsum_cnk.sumcena,Sumsum_cnk.sumpocet,Sumsum_cnk.summnoz,Sumsum_cnk.last
FROM Obj_polozky, Cenik, Obj_header, Obchodni_partneri, Sumsum_cnk
WHERE Obchodni_partneri.id=Obj_header.id_org AND Obj_header.id_dobj=Obj_polozky.id_dobj AND Obj_polozky.id_cnk=Cenik.id_cenik
AND (Obj_header.potvrzena=true AND Obchodni_partneri.intr_user<>"" AND Obj_header.zpracovana<>NONEDATE AND Obj_header.storno<>true)