Synoptek interview question

sql query , schenario based qestion