PROMPT Pokrenuta skripta n3943_ipkakar_del.sql

SELECT COUNT (1) AS ipkakar_kol FROM (
  SELECT broj, COUNT (id) FROM ipka_kartice GROUP BY broj HAVING COUNT (id) > 1);

BEGIN
  FOR c IN (
    SELECT broj, MAX (id) AS max_id
      FROM ipka_kartice
     GROUP BY broj
    )
  LOOP
    DELETE
      FROM ipka_kartice
     WHERE broj = c.broj
       AND id < c.max_id;
  END LOOP;
  COMMIT;
END;
/

SELECT COUNT (1) AS ipkakar_kol FROM (
  SELECT broj, COUNT (id) FROM ipka_kartice GROUP BY broj HAVING COUNT (id) > 1);
