i sitting in interview , person evaluating me asked me write script following scenario. according him, has imported database other system contains table named employees. there 3 columns in table emp_name, age , salary table doesn't have id column. asked me write script add id column in table , single update statement updation of id column sequential values( first record starts 1,2,3 , onwards). added id column not write update statement , after week gone, still can't figure out how can achieve that. idea on how should go that?
update employees set id=(select count(*) employees e2 e2.emp_name < e1.emp_name)+1 employees e1
only if fails (duplicate names) add second condition subselect add in age , possibly salary differentiate records.
Comments
Post a Comment