-- View: public.invalid_vehicle

-- DROP VIEW public.invalid_vehicle;


create table invalid_vehicle as
select * from vehicle_vehicle vv  where trim(lower(license_plate))  in
(select trim(lower(license_plate)) license_plate from vehicle_vehicle vv group by  trim(lower(license_plate)) having count(trim(lower(license_plate))) > 1)
union
select * from vehicle_vehicle vv  where license_plate like '%.%'
union
select * from vehicle_vehicle vv  where length(license_plate) < 3
union
select * from vehicle_vehicle vv  where license_plate like '%0000%';

-- ALTER TABLE public.invalid_vehicle
    --OWNER TO postgres;

