1 2 3 4 5 6 7 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 );