mirror of
https://codeberg.org/demostf/db.git
synced 2026-06-03 18:14:08 +02:00
add view that pairs users with their most used name
This commit is contained in:
parent
8c29e0fe41
commit
317b0b1c9e
1 changed files with 12 additions and 0 deletions
12
schema.sql
12
schema.sql
|
|
@ -562,6 +562,18 @@ CREATE MATERIALIZED VIEW name_list AS
|
|||
|
||||
CREATE INDEX alias_name_trgm_idx ON name_list USING GIN (name gin_trgm_ops);
|
||||
|
||||
CREATE MATERIALIZED VIEW users_named AS
|
||||
with names as
|
||||
(
|
||||
select name, count, user_id,
|
||||
rank() over (partition by user_id order by user_id, count desc) rn
|
||||
from name_list
|
||||
)
|
||||
select id, steamid, n.name, avatar, token
|
||||
from names n
|
||||
inner join users u on u.id = n.user_id
|
||||
where rn = 1;
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue