-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueries.sql
More file actions
28 lines (24 loc) · 780 Bytes
/
queries.sql
File metadata and controls
28 lines (24 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Badges
SELECT DISTINCT b.user_id, b.date, b.name
FROM `bigquery-public-data.stackoverflow.badges` b
WHERE b.name IN ('Mortarboard', 'Epic', 'Legendary')
-- Comments
SELECT c.creation_date, c.user_id
FROM `bigquery-public-data.stackoverflow.comments` c
RIGHT JOIN (
SELECT DISTINCT b.user_id
FROM `bigquery-public-data.stackoverflow.badges` b
WHERE b.name IN ('Mortarboard', 'Epic', 'Legendary')
) AS b
ON c.user_id=b.user_id
-- Posts
SELECT
p.creation_date, p.post_type_id, p.owner_user_id
FROM `bigquery-public-data.stackoverflow.stackoverflow_posts` p
RIGHT JOIN (
SELECT DISTINCT b.user_id
FROM `bigquery-public-data.stackoverflow.badges` b
WHERE b.name IN ('Mortarboard', 'Epic', 'Legendary')
)
ON owner_user_id=user_id
WHERE p.post_type_id < 3