Philips interview question

sql joins , sorting in ds