select count(distinct a.userid) as users, b.m_name from Table1 a,Table2 b where a.conid=b.vid_id
and b.m_name and a.duration>0 and b.runtime>0
group by b.m_name,a.duration,b.runtime having sum(a.duration)/b.runtime >=50
답변 31개

Thanks for providing the sample.
As some users have 2 or more records per movie, you have to get SUM of Duration but while you must NOT summarize Runtime. So the calculation of percentage should be
And then you can calculate the percentage of users who spent time to see the movies.
<compute using for table calculation>