Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

author-stats.sql 2.0 KB

You have to be logged in to leave a comment. Sign In
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  1. --- #dep author-info
  2. --- #table integration_stats
  3. --- #step Set up statistics table
  4. DROP TABLE IF EXISTS integration_stats CASCADE;
  5. CREATE TABLE integration_stats (
  6. dataset VARCHAR NOT NULL,
  7. gender VARCHAR NOT NULL,
  8. n_books INTEGER,
  9. n_actions INTEGER
  10. );
  11. --- #step Count LOC integration statistics
  12. WITH
  13. books AS (SELECT DISTINCT cluster
  14. FROM locmds.book_rec_isbn JOIN isbn_cluster USING (isbn_id))
  15. INSERT INTO integration_stats (dataset, gender, n_books)
  16. SELECT 'LOC-MDS', gender, COUNT(cluster)
  17. FROM books JOIN cluster_first_author_gender USING (cluster)
  18. GROUP BY gender;
  19. --- #step Count BookCrossing integration statistics
  20. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  21. SELECT 'BX-I', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  22. FROM bx.add_action
  23. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  24. GROUP BY COALESCE(gender, 'no-book');
  25. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  26. SELECT 'BX-E', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  27. FROM bx.rating
  28. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  29. GROUP BY COALESCE(gender, 'no-book');
  30. --- #step Count Amazon integration statistics
  31. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  32. SELECT 'AZ', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  33. FROM az.rating
  34. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  35. GROUP BY COALESCE(gender, 'no-book');
  36. --- #step Count GoodReads integration statistics
  37. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  38. SELECT 'GR-I', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  39. FROM gr.add_action
  40. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  41. GROUP BY COALESCE(gender, 'no-book');
  42. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  43. SELECT 'GR-E', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  44. FROM gr.rating
  45. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  46. GROUP BY COALESCE(gender, 'no-book');
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...