User Tools

Site Tools


wiki:postgres:pg_tune_kurs_aggregatfunction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

wiki:postgres:pg_tune_kurs_aggregatfunction [2017/09/28 12:21] (current)
Line 1: Line 1:
 +====== Aggregat Funktionen ======
  
 +  GROUP BY
 +
 +====== Window Funktionen ======
 +Window Funktionen bedeuten : "Ich im Verhältnis zu einem anderen in einer Gruppe(=Window)"​.
 +  temp# \dfwS --listet Window Funktionen
 +
 +  temp# SELECT *, rank() Over (Order by income Des) from t_test;
 +  ​
 +  ... Over (Partition by country
 +  ​
 +  temp# SELECT *, dense_rank() Over (Partition by country order by income desc),
 +                        rank() Over (Order by income desc) FROM t_test; ​         /​*Unterschied zw. rank u. dense_rank ist
 +                                                                                   wie verhält es sich wenn zwei gleichauf sind
 +                                                                                   (z.B. zwei Erste, gibt es dann einen Zweiten)*/
 +  ​
 +  temp# SELECT *, income - avg(income) Over() FROM t_test;
 +  ​
 +  temp# SELECT *, ntile(2) Over (Order by income) FROM t_test; -- 2 gleiche Teile (reichster und ärmster Teil)
 +  ​
 +  temp# SELECT *, lag(income, 1) Over (Order by income) FROM t_test; --lag verschiebt (z.B. Temperaturdifferenz von einem Tag zum Nächsten).
 +  ​
 +  temp# SELECT *, sum(income) Over (partition by gender Order by income); -- kumulierte Summe.
wiki/postgres/pg_tune_kurs_aggregatfunction.txt · Last modified: 2017/09/28 12:21 (external edit)