ServiceTitan interview question

One easy and one medium algorithm question. With a very simple sql query to write.