Interview Answer

When debugging, novices insert corrective code; experts remove defective code. Richard Pattis

write query to sort the employee based on the salary

April 10, 2016 9:51 pm

Comments



write query to sort the employee based on the salary


The order by uses to sort the records from the table result set. The order can be ascending or descending.


													desc HR.employees;
													
													Name           Null     Type         
													-------------- -------- ------------ 
													EMPLOYEE_ID    NOT NULL NUMBER(6)    
													FIRST_NAME              VARCHAR2(20) 
													LAST_NAME      NOT NULL VARCHAR2(25) 
													EMAIL          NOT NULL VARCHAR2(25) 
													PHONE_NUMBER            VARCHAR2(20) 
													HIRE_DATE      NOT NULL DATE         
													JOB_ID         NOT NULL VARCHAR2(10) 
													SALARY                  NUMBER(8,2)  
													COMMISSION_PCT          NUMBER(2,2)  
													MANAGER_ID              NUMBER(6)    
													DEPARTMENT_ID           NUMBER(4)   
													

Solution

   					 
												select first_name, last_name, email, salary from HR.employees order by salary
																	    

Comments



Please login to add comments.