Skip to content

Commit f3098a1

Browse files
committed
ENH: Adds queries to create accepted_answer_id and qn_ans_timing tables
1 parent dd72cb2 commit f3098a1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.todo
12
*.7z
23
*.xml
34
*.pyc

sql/PostHistory_post.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,26 @@ CREATE INDEX ph_creation_date_idx ON PostHistory USING btree (CreationDate)
99
WITH (FILLFACTOR = 100);
1010
CREATE INDEX ph_userid_idx ON PostHistory USING btree (UserId)
1111
WITH (FILLFACTOR = 100);
12+
13+
14+
CREATE TABLE accepted_answer_id as SELECT DISTINCT acceptedanswerid FROM posts;
15+
16+
DROP TABLE qn_ans_timing;
17+
18+
CREATE TABLE qn_ans_timing AS
19+
SELECT
20+
p.id,
21+
p.tags,
22+
p.owneruserid,
23+
p.creationdate as qn_creation_ts,
24+
h.creationdate as ans_creation_ts,
25+
p.acceptedanswerid,
26+
h.userid as answered_by
27+
FROM posts p, posthistory h
28+
WHERE p.acceptedanswerid is not null
29+
AND h.postid in (
30+
SELECT *
31+
FROM accepted_answer_id
32+
)
33+
34+
AND p.acceptedanswerid=h.postid;

0 commit comments

Comments
 (0)