Talentica interview question

sql queries join