-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40d6b27
commit a6e528d
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |