From 1a95bd4e610770bed1571de6ddf572d5590561d9 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Mon, 2 Mar 2020 16:21:26 +0000 Subject: Rework table structure add sql queries --- sql/weighted.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sql/weighted.sql (limited to 'sql/weighted.sql') 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 +); -- cgit v1.2.3-70-g09d2