Comment

Comment by deepsun

Checked just the first two answers:

1. MoM Percent Change

It's better to use windowing functions, I believe it should be faster than self-join.

2. It seems that the first solution is wrong -- it returns whether "a"-s parent is Root/Inner/Leaf, not "a" itself.

I'd instead add a "has_children" column to the table, and then it would be clear.

Second solution works, but without optimization it's 1 query per row due to nested query -- slow, but not mentioned.

parent deepsun 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton