daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE tst_ratings (
  2.     player varchar PRIMARY KEY,
  3.     level integer,
  4.     last_updated timestamp
  5. );
  6.      
  7. SELECT *
  8. FROM tst_ratings
  9. ORDER BY level desc, last_updated asc
  10. LIMIT 100;
  11.      
  12. SELECT count(*)
  13. FROM tst_ratings
  14. WHERE level > 164 or (level = 164 and last_updated < '2018-02-25 02:40:04.028757';
  15.      
  16. CREATE MATERIALIZED VIEW v_tst_ratings AS
  17. SELECT player, level, last_updated, ROW_NUMBER() OVER(ORDER BY level desc, last_updated asc) AS rnk
  18. FROM tst_ratings;
  19.  
  20. CREATE UNIQUE INDEX v_tst_ratings_idx ON v_tst_ratings(player);
  21.      
  22. SELECT player, rnk
  23. FROM  v_tst_ratings
  24. LIMIT 100;
  25.      
  26. SELECT rnk
  27. FROM v_tst_ratings
  28. WHERE player = 'some_id';
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top