Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
histogram to percentiles
CREATE TABLE ranks AS SELECT make, model, rank1_cnt, rank2_cnt, rank3_cnt FROM ( VALUES ( 'samsung' , 's6', 1 , 4 , 2 ), ( 'samsung' , 's7' , 3 , 2 , 1), ( 'lg' , 'g7', 1 , 1 , 3) ) AS t(make, model, rank1_cnt, rank2_cnt, rank3_cnt); SELECT make, model, percentile_disc(0.5) WITHIN GROUP (ORDER BY gs1.x) FROM ( SELECT make, model, ARRAY[rank1_cnt, rank2_cnt, rank3_cnt] FROM ranks ) AS t(make, model, ranks) CROSS JOIN LATERAL generate_series(1,3) AS gs1(x) CROSS JOIN LATERAL generate_series(1,ranks[gs1.x]) AS gs2(x) GROUP BY make, model ORDER BY make;
run
|
edit
|
history
|
help
0
Select rows only with values separated by a given interval from other ...
test jsonb_set of PostgreSQL
PC02-DB-UTEC
Christmas Tree Generator
Assignment 1(SET A)
2
PostreSQL: warehouse table
Shortest "path" between two employees across companies
Projeto
loggin_trigger-audit