Re: aggregate and order by
От | Gregory Stark |
---|---|
Тема | Re: aggregate and order by |
Дата | |
Msg-id | 87abonr1kf.fsf@oxford.xeocode.com обсуждение исходный текст |
Ответ на | aggregate and order by ("Matthew Dennis" <mdennis@merfer.net>) |
Ответы |
Replication Monitoring
|
Список | pgsql-general |
"Matthew Dennis" <mdennis@merfer.net> writes: > So, my question is if I can have PostgreSQL honor order by clauses such as: > > select trip_id, avg_vel(position, pos_time) > from (select position, pos_time, trip_id from data order by pos_time) sorted_data > > Would this in fact guarantee that the rows are passed into the aggregate in > the order specified? Yes. AFAIK this isn't covered by the spec but it works in Postgres and we know there are people depending on it so we wouldn't break it without a big notice and presumably some replacement. > Other suggestions/discussions/questions/etc are welcome. Good luck, this looks pretty painful to get right. Keep in mind you have to keep all your state in the state data. If you keep a temporary variable outside that data then your function won't work if it's called twice in the same query like "select avg_vel(position, pos_time), avg_vel(position2, pos_time2) from ..." -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!
В списке pgsql-general по дате отправления: