JNET Technologies interview question

Very difficult sql queries