多个窗口功能可以应用到同一个分区吗?(如果我用的词不正确,请纠正我。* ]( n7 Q: ~# K% ~! c+ ?
例如你可以 " q4 W3 c% {* F1 w \/ qSELECT name,first_value() over (partition by name order by date) from table1但是有没有办法做类似的事情: : \8 ^2 ?! z" M5 k% RSELECT name,(first_value() as f,last_value() as l (partition by name order by date)) from table1在同一个窗口应用两个函数?* ?& c7 Z1 n* G) h0 m; R2 U
参考:http :; i% i) f& A" r" d$ \
//postgresql.ro/docs/8.4/static/tutorial-3 ~0 o: Z. ~+ H3 Z5 k
window.html + l8 ]$ Q4 Q) p: r , S/ k- j$ [% P% Q* z" z解决方案: 0 V) I' M2 P+ A7 I6 B( c) M" D 你不仅可以使用每个选择的窗口吗? / l- h: L i9 F* C就像是+ P9 S8 f9 D# ^# V! 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你也可以从你的参考中做到这一点 0 u ]. j. R" }( XSELECT sum(salary) OVER w,avg(salary) OVER wFROM empsalaryWINDOW w AS (PARTITION BY depname ORDER BY salary DESC)