Another variation:
select avg(max) from (select distinct max(val) over(partition by id) frommytable);
Cheers,Greg
--Crunchy Data - https://www.crunchydata.comEnterprise Postgres Software Products & Tech Support