Treebo Hotels interview question

SQL query with group by condition