Don't have Telegram yet? Try it now!
https://mirkomaggioni.com/2018/11/15/dinamically-grouping-in-t-sql/
Dinamically grouping in T-SQL