Problem description

A table stores multiple time intervals for each account, and the intervals may overlap.

Source data:

Expected output (merge overlapping intervals for each account):

Take account A as an example: