I have a table:
country ID type
US a1 upload
US a1 delete
US a1 delete
US a2 upload
US a2 upload
US a2 delete
IT k2 upload
IT k2 upload
IT k2 delete
I want to get table with unique countries, number of unique ID's in it and average percent of "delete" value in type among each ID in country. So desired table must look like:
country ID_cnt delete_perc
US 2 0.5
IT 1 0.33
Its 0.498 since for ID a1 its 0.66 and for a2 it's 0.33, s (0.66 + 0.33)/2 = 0.5
How to do that? I need it with Presto