You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create view movie_by_genre as select movieid, genre from (select movieid, split(genres, '\\|') genres from movies) t lateral view explode(genres) t as genre;
101
-
<CODE>
102
-
</br>
94
+
#### Create exploded view of movie id and genre
95
+
```
96
+
CREATE view movie_by_genre as SELECT movieid, genre FROM
97
+
(
98
+
SELECT movieid, split(genres, '\\|') genres FROM movies
create temporary table movie_by_user_genre as select t1.*, t2.rating,t2.userid from movie_by_genre t1 left join ratings t2 on t1.movieid = t2.movieid where t2.rating >= 4;
110
-
111
-
create temporary table user_by_genre_totalrating as select userid, genre, sum(rating) total_rating from movie_by_user_genre group by userid, genre;
112
+
```
113
+
CREATE TEMPORARY TABLE user_by_genre_totalrating as
114
+
SELECT userid, genre, sum(rating) total_rating
115
+
FROM movie_by_user_genre GROUP BY userid, genre;
116
+
```
112
117
113
-
select * from
114
-
(select userid, genre, row_number() over (partition by userid order by total_rating desc) row_num from user_by_genre_totalrating) t where t.row_num <= 3;
115
-
</CODE>
116
-
</br>
118
+
```
119
+
SELECT * FROM
120
+
(SELECT userid, genre, ROW_NUMBER() OVER (PARTITION by userid ORDER BY total_rating desc) row_num
0 commit comments