postgresql7.1 select count(*) as duplicate where exists (select option_id from ttracker_options where package_id = :package_id and function = :function and option_id <> :option_id and (value = :value or upper(name) = upper(:name)))