diff --git a/Vinod_Malleshappa_LAB2_Exercise_1.sql b/Vinod_Malleshappa_LAB2_Exercise_1.sql new file mode 100644 index 0000000..2b65da8 --- /dev/null +++ b/Vinod_Malleshappa_LAB2_Exercise_1.sql @@ -0,0 +1,27 @@ +WITH + Movie_Ranking AS ( + SELECT + Release_Date, + Movie_Title, + Production_Budget, + RANK() OVER(PARTITION BY EXTRACT(YEAR FROM Release_Date) + ORDER BY + Production_Budget DESC) AS rank + FROM + `nttdata-c4e-bde.uc1_2.Movie` + WHERE + Release_Date BETWEEN '2016-01-01' + AND '2020-12-31' ) +SELECT + EXTRACT(YEAR + FROM + Release_Date) AS year, + Movie_Title, + Production_Budget, + rank +FROM + Movie_Ranking +WHERE + rank <=10 +ORDER BY + year DESC \ No newline at end of file diff --git a/Vinod_Malleshappa_LAB2_Exercise_3.sql b/Vinod_Malleshappa_LAB2_Exercise_3.sql new file mode 100644 index 0000000..bb04f95 --- /dev/null +++ b/Vinod_Malleshappa_LAB2_Exercise_3.sql @@ -0,0 +1,8 @@ +SELECT + visitId, + visitStartTime, + h.page.pageTitle AS pageTitle, + h.page.pagePath AS pagePath +FROM + `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`, + UNNEST(hits) AS h \ No newline at end of file diff --git a/Vinod_Malleshappa_LAB2_Exercise_4.sql b/Vinod_Malleshappa_LAB2_Exercise_4.sql new file mode 100644 index 0000000..1cec831 --- /dev/null +++ b/Vinod_Malleshappa_LAB2_Exercise_4.sql @@ -0,0 +1,13 @@ +SELECT + PARSE_DATE('%Y%m%d',date) date, + h.page.pagePath pagePath, + COUNT(h.page.pagePath) counter +FROM + `bigquery-public-data.google_analytics_sample.ga_sessions_201707*`, + UNNEST(hits) AS h +GROUP BY + date, + pagePath +ORDER BY + date, + counter DESC \ No newline at end of file diff --git a/Vinod_Malleshappa_LAB2_Exercise_5.sql b/Vinod_Malleshappa_LAB2_Exercise_5.sql new file mode 100644 index 0000000..81e9db4 --- /dev/null +++ b/Vinod_Malleshappa_LAB2_Exercise_5.sql @@ -0,0 +1,16 @@ + +SELECT + DISTINCT us.id AS id_user, + COUNT(pa.score) OVER(PARTITION BY PA.owner_user_id ORDER BY pa.owner_user_id) AS count +FROM + `bigquery-public-data.stackoverflow.posts_answers` pa +INNER JOIN + `bigquery-public-data.stackoverflow.users` us +ON + pa.owner_user_id = us.id + AND extract(year from pa.creation_date) = 2010 +ORDER BY + count DESC +LIMIT + 10 +