You are on page 1of 2

1) Show sysdate

==> select sysdate from emp;

2) Display emp_id, name and salary increased by 12.5% (*1.25)(in whole number).
Label the
column as "New salary"
==> select employee_id,first_name
salary,salary*12+0.125 "New salary"
from emp;

3) Modify above query to show difference between new salary and old salary.
(subtract
operation)
==> select salary "old salary",
salary-2000 "New Salary"
from emp;

4) Write a query that displays the lastname of employee(INIT cap) and length of
last name whose
first name starts with A or S. sort the result by last name
==> select last_name
"initcap",initcap(length(last_name))"Length"
from emp
where first_name like'%A%' or first_name like '%S%'
order by last_name;

5) Modify above query to prompt user the starting letter of first name and get the
results.
==> select*from emp
where first_name like'%a%';

6) Display the last name of employees and calculate no of months between today and
the day
they were hired.label the column as "months_worked". Order the result by months
worked.
==>

7) Write a query to show first name and salary, format the salary to 15 characters
left padded
with $, label the column as salary
==> select first_name, salary,lpad(salary,15,'$')from emp;

8) Display last name of employees and the no of weeks worked in the department Id=
3.Label the
column as "Weeks_worked".truncate the no of weeks to 0 decimal places. show the
results in
descending order of "weeks_ worked"
==>

9) Write a query to update the portion of the email in the employees table, the
substring 'gmail'
will be replaced by 'yahoo'.
==> select replace(email','yahoo')"yahoo"from emp;

10) Write a query to get the details of the employees where the length of the first
name greater
than or equal to 5.
==> select*from emp
where length(first_name)>=5;

11) Write a query to display the length of first name for employees where last name
contain
character 'c' after 2nd position.
==>

You might also like