Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
VinodMalleshappa authored Aug 26, 2022
1 parent 40d6b27 commit a6e528d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Vinod_Malleshappa_LAB2_Exercise_2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# There are various type to collect data, i think need to pair the OS and Browser columns, to get more accuracy indata

WITH
country_rank AS (
SELECT
DISTINCT geoNetwork.country AS country,
device.operatingSystem AS operatingSystem,
device.browser AS browser,
RANK() OVER(PARTITION BY geoNetwork.country ORDER BY device.browser ) rank
FROM
`bigquery-public-data.google_analytics_sample.ga_sessions_20170801`
WHERE
device.isMobile = TRUE
AND geoNetwork.country != '(not set)'
AND device.operatingSystem != '(not set)'
AND device.browser != '(not set)'
GROUP BY
country,
device.operatingSystem,
device.browser )
SELECT
country,
ARRAY_AGG(STRUCT(operatingSystem,
browser,
rank)) country_rank
FROM
country_rank
WHERE
rank <4
GROUP BY
country,
rank
ORDER BY
country
22 changes: 22 additions & 0 deletions Vinod_Malleshappa_LAB2_Exercise_6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SELECT
DISTINCT us.id AS id_user,
COUNT(sfp.accepted_answer_id) AS count # OVER(PARTITION BY us.id ORDER BY us.id)
FROM
`bigquery-public-data.stackoverflow.posts_answers` pa
INNER JOIN
`bigquery-public-data.stackoverflow.users` us
ON
pa.owner_user_id = us.id
INNER JOIN
`bigquery-public-data.stackoverflow.stackoverflow_posts` sfp
ON
sfp.accepted_answer_id = pa.id
AND EXTRACT (YEAR
FROM
pa.creation_date)= 2010
GROUP BY
id_user
ORDER BY
count DESC
LIMIT
10
22 changes: 22 additions & 0 deletions Vinod_Malleshappa_LAB2_Exercise_8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SELECT
DISTINCT cmt.committer.name AS name,
COUNT( LANGUAGE.name ) AS count
FROM
`bigquery-public-data.github_repos.languages` lng,
UNNEST(LANGUAGE) AS
LANGUAGE
INNER JOIN
`bigquery-public-data.github_repos.sample_commits` cmt
ON
lng.repo_name = cmt.repo_name
WHERE
EXTRACT(year
FROM
cmt.committer.date) =2016
AND LANGUAGE.name = 'Java'
GROUP BY
name
ORDER BY
count DESC
LIMIT
10
19 changes: 19 additions & 0 deletions Vinod_Malleshappa_LAB2_Exercise_9.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SELECT
DISTINCT repo_name,
df.new_path AS file,
committer.date AS date,
LAG(
COMMIT
) OVER (PARTITION BY df.new_path ORDER BY committer.date ASC) AS previous_commit,
COMMIT
,
LEAD(
COMMIT
) OVER (PARTITION BY df.new_path ORDER BY committer.date ASC) AS next_commit
FROM
`bigquery-public-data.github_repos.sample_commits` AS cmt,
UNNEST(difference) df
WHERE
df.new_path = 'kernel/acct.c'
ORDER BY
date

0 comments on commit a6e528d

Please sign in to comment.