多个窗口功能可以应用到同一个分区吗?(如果我用的词不正确,请纠正我。 : ?) C' e+ o! ^/ w# a+ @, G例如你可以5 Q+ u3 W9 t5 A" Q; e
SELECT name,first_value() over (partition by name order by date) from table1但是有没有办法做类似的事情: ; ~. \2 J, M0 e1 h. O; q- g9 A; WSELECT name,(first_value() as f,last_value() as l (partition by name order by date)) from table1在同一个窗口应用两个函数? 7 Q" J' H6 P. {2 X% `参考:http :8 I+ q' I# a' l0 I- z C8 |6 B8 {
//postgresql.ro/docs/8.4/static/tutorial-; R* V2 J$ \* s. _
window.html 8 p s; }: Z4 I! R# o, V( P' b + d8 K j$ h! O4 q% u! ] 解决方案: 8 }( |; \# }; @
你不仅可以使用每个选择的窗口吗? 6 }$ A6 K1 B+ I( p- n" @2 N U4 ?, x1 Y就像是 1 O }- `$ u$ B# \SELECT name, first_value() OVER (partition by name order by date) as f, last_value() OVER (partition by name order by date) as l from table1你也可以从你的参考中做到这一点 3 L' B" {# w4 C6 s; v& S" s9 f9 pSELECT sum(salary) OVER w,avg(salary) OVER wFROM empsalaryWINDOW w AS (PARTITION BY depname ORDER BY salary DESC)