Digitas interview question

Code in SQL or Python