Noom Interview Question

2 SQL questions, 1 around regular group by and other a little complicated including, windowing and aggregating function