added db functions for window functionality

add ORDER BY ?