sql - BiqQuery - select values with max function -
i have kind of table (just example.. in case table has on 60000 records)
i know how make select gender rate movieid (or songid) higher rate?
i query this:
select * ( select avg(rating)as rating, movieid,'m' gender [of7.test] gender = 'm' group movieid ) , ( select avg(rating)as rating, movieid,'f' gender [of7.test] gender = 'f' group movieid ) order movieid
and king of result:
question is: there difference in ratings between genders, gender rates movies higher ratings, difference significant?
- is there way modify query max(rate) songid/movieid , gender?
thank you
i've never used bigquery before should work:
select movieid, case when f_rate >= m_rate f_rate else m_rate end max_rating, case when f_rate > m_rate 'females rated higher' when f_rate < m_rate 'males rated higher' else 'rated equal' end who_rated_it_higher, abs(f_rate - m_rate) --absolute value of difference ( select movieid, avg(case when gender = 'f' rating end) f_rate, avg(case when gender = 'm' rating end) m_rate cte group movieid )
if have questions or need else, let me know.
Comments
Post a Comment