SQL Server Database Interview Questions and Answers
SQL Server Database Interview Questions and Answers 1) You have two columns in source table in which the col1 may contain duplicate values, All the duplicate values in col2 will be transformed as comma separated in the column col2 of target table Answer : --Select Query in table Query : select * from tbl1 col1 col2 a x b y c z a m b n Solution : Select col1, STRING_AGG(col2,',') Result from tbl1 group by col1 --OR select col1, STRING_AGG (col2,',') WITHIN GROUP (ORDER BY col2 ) Result from tbl1 group by col1 Output : col1 Result a x ,m b n ,y c z 2) Reading a source file with salary prefix $, in the target the Sal column must store in number . Answer: select * from source; empno ename job managerid firedat...
Comments
Post a Comment