Insert into KPI_DATA (ID, ClientID, PMonth, sCode, Testcode, Amount) values
Select ID, ClientID, PMonth, sCode, Testcode, count(ID) as Amount from
Select '1' as ID,Folders.clientID, round(to_date(folders.AANM_DATE), 'MONTH') as PMonth, orders.scode, ordtask.testcode from folders, orders, ordtask where
folders.aanm_date between '1-jul-07' and '6-jul-07' and folders.divisie = 'FOOD' and folders.clientID in (5280, 5281, 5282, 5283, 5284) and ordtask.ordno = orders.ordno and orders.folderno = folders.folderno and folders.releasetime < '14:00' and fldsts <> 'Hold'
GROUP BY ID, clientID, PMonth, scode,testcode