List the EmpNo,EName,Sal Daily Sal of all Emps in the ascending order of annual salary?

 Posted by aswinialuri-19361 on 7/30/2013 | Category: .NET Framework Interview questions | Views: 2226 | Points: 40

Select EmpNo,EName,Sal,Sal/30,12 * Sal annual salary from Emp order by annual salary
you can detect by this query

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Bandi on: 8/12/2013 | Points: 10
Hi Aswini,
You will get error with the above code because of alias name which is composed of two words... ( Annual salary)
-- Listed out the different types of answers for the above interview question... The query should be as follows
1) Select EmpNo,EName,Sal, Sal/30,12 * Sal [b][annual salary][/b] from Emp order by [b][annual salary][/b] -- by using brackets
2) Select EmpNo,EName,Sal, Sal/30,12 * Sal [b]"annual salary"[/b] from Emp order by [b]"annual salary"[/b] -- By using double quotes
3) Select EmpNo,EName,Sal, Sal/30,12 * Sal [b]annualSalary[/b] from Emp order by [b]annualSalary[/b] -- without using space between words in the alias column name
4) Select EmpNo, EName, Sal, Sal/30, 12 * Sal [b]annualSalary[/b] from Emp order by [b]5[/b] -- Here 5 is the column position in the SELECT statement
5) Select EmpNo, EName, Sal, Sal/30, 12 * Sal [b]annualSalary[/b] from Emp order by [b]12*Sal[/b] -- By using actual expression

Login to post response