Accenture interview question

tell me how you do this in SQL