cermati interview question

My approach to solve a use case using SQL