Wednesday, September 3, 2008

Lag function can make query to have a default order by

select album_id, client_id, lag(client_id) over (partition by album_id order by submit_ts asc) lag_client_idfrom stat.submit_factwhere album_id = 440556

In this query, I did not put a 'order by' at the end of the query. But because I use lag function, it will make the whole query order by submit_ts. It makes sense.

No comments: