Błąd to: To rozwiąże ten problem: SELECT cr.plate, car_id_seq.nextval FROM (SELECT DISTINCT plate FROM cars_rentals) cr