top | item 20876937

(no title)

AdamM12 | 6 years ago

Anyone have an example of using window functions in a non time series data set? Kinda seems like a bit of a flag in my head that if I'm asked to do some analysis w/ time series data (depending on the question) a window function might be a good the tool. Reading this you can tell I'm not particularly fluent in them. We use them at work and I was asked during my interview about them (did not know but got job anyway).

discuss

order

ianamartin|6 years ago

Say you have to grab a bunch of files a few times a day and zip them up and drop them on and endpoint somewhere. But the endpoint has a max file size for a single upload.

If you have a table of metadata about your files (zipped_size and location, for example) you can window on the sum of the zipped_size to collect some number of files you can get that will be under the file size limit.

taffer|6 years ago

Window functions can be used to compute the median:

    select percentile_disc(0.5) within group (order by things.value)
    from things