Create a query to display the last name and salary for all e
Create a query to display the last name and salary for all employees. Format the salary to be 15 characters long, left-padded with the $ symbol. Label the column SALARY.
Create a query that displays the first eight characters of the employees’ last names and indicates the amounts of their salaries with asterisks. Each asterisk signifies a thousand dollars. Sort the data in descending order of salary. Label the column EMPLOYEES_AND_THEIR_SALARIES.
Create a query to display the last name and the number of weeks employed for all employees in department 90. Label the number of weeks column as TENURE. Truncate the number of weeks value to 0 decimal places. Show the records in descending order of the employee’s tenure.
Note: The TENURE value will differ as it depends on the date on which you run the query.
Solution
1 Select last_name,LPAD(salary,15,\'$\') AS SALARY from employees;
2. Select rpad(last_name,8)||\' \'||rpad(\' \',salary/1000+1,\'*\') AS EMPLOYEES_AND_THEIR_SALARIES from employees order by salary DESC;
3. Select last_name,TRUNC((SYSDATE-HIREDATE)/7) AS TENURE from employees where department =90 order by TENURE;
