Query to Find Monthly Salary of Employee if Annual salary is Given?

  • Interview Question:-

How to find Monthly Salary of Employee from Employee table if annual salary is given?

  • Answer:

   select Employee_name,Salary/12 as ‘Monthly Salary’ from employee;

  • Explaination of Query :

As this query is really very simple to look but in this simple query we are explaining the concept of aliases.Following are the steps of executing this Query:

  • step1:

      Select * from Employee;

Output:

Employee_num Employee_name Department Salary
1 Amit OBIEE 680000
2 Rohan OBIEE 550000
3 Rohit OBIEE 430000
  • Step2 :

After this  We need to fetch only 2 columns from the Employee table.So following is the query to fetch required columns:

   Select Employee_name,Salary from Employee;

Output:

Employee_name Salary
Amit 680000
Rohan 550000
Rohit 430000
  • Step3:Fetch the actual records from query

select Employee_name,Salary/12 as ‘Monthly Salary’ from employee;

Output:

Employee_name Monthly Salary
Amit 56667
Rohan 45833
Rohit 35834

Here in above query we are taking alias for Salary column.Alias concept is very useful to give the business meanings (as per requirements) to the table column.We will directly divide the column which has number,float,double or any other numeric datatype.In above example we have considered the datatype as integer number so results of query has been rounded off.So In SQL you can directly divide salary by 12 so that you will Find Monthly Salary of Employee.There is no need to use calender functions,Month functions in Oracle.

Using Following Link You Will be Able to see Complex SQLS:

>>>>>>>>>>>>>>>Click Here to See Complex SQLs<<<<<<<<<<<<<<<<<<<<<<

4 Replies to “Query to Find Monthly Salary of Employee if Annual salary is Given?”

  1. not working amit, it shows

    ORA-00923: FROM keyword not found where expected

    this show the crt results
    “select e_name, sal/12 as monthly from emp;”

Comments are closed.