3 ms·
> It's better to use windowing functions, I believe it should be faster than self-join. Your statement is making the assumption you have completely dense data
by meritt 6y ago
> It's better to use windowing functions, I believe it should be faster than self-join.
Your statement is making the assumption you have completely dense data and you can simply offset a number of rows to get the desired denominator. Sparse data is a very common occurrence, and now your MoM/YoY/XoX queries are completely incorrect.
- radiowave 6y agoGood point. I often find the easiest approach is to join against a sequence to 'unsparsify' the data, then use the window function. I'd guess this is likely still faster than a self-join, unless the data is very sparse.