summaryrefslogtreecommitdiff
path: root/sql/weighted.sql
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-03-02 16:21:26 +0000
committerDennis Kobert <dennis@kobert.dev>2020-03-02 16:21:26 +0000
commit1a95bd4e610770bed1571de6ddf572d5590561d9 (patch)
treebfd5b41bf0ee9ec9b49a2b31e212185ddb888aaa /sql/weighted.sql
parent17a305d420c4fd88fcaabb479164e6095303f7fc (diff)
Rework table structure
add sql queries
Diffstat (limited to 'sql/weighted.sql')
-rw-r--r--sql/weighted.sql8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/weighted.sql b/sql/weighted.sql
new file mode 100644
index 0000000..dfa23c1
--- /dev/null
+++ b/sql/weighted.sql
@@ -0,0 +1,8 @@
+CREATE OR REPLACE VIEW user_track_weighted AS (
+ SELECT *, "count" / (
+ SELECT SUM("count")
+ FROM user_track ut
+ WHERE ut.user_id = user_id
+ )::decimal AS score
+ FROM user_track
+);