TP interview question

mostly sql scripting