SECTION 1 LESSON 2
1. Display Oracle database employee last_name and salary for employee_ids between 100 and 102. Include a third column that divides each salary by 1.55 and rounds the result to two decimal places.
----select last_name,round(salary/1.55,2)
from employees
where employee_id between 100 and 102;
2. Display employee last_name and salary for those employees who work in department 80. Give each of them a raise of 5.33% and truncate the result to two decimal places.
----select last_name,salary,trunc(salary+salary*0.0533,2)
from employees
where department_id=80;
3. Use a MOD number function to determine whether 38873 is an even number or an odd number.
----select mod(38873,2)
from dual;
(the remainder is 1, so 38873 is an odd number.)
4. Use the DUAL table to process the following numbers:
845.553 - round to one decimal place
30695.348 - round to two decimal places
30695.348 - round to -2 decimal places
2.3454 - truncate the 454 from the decimal place
----select round(845.553,1)
from dual;
select round(30695.348,2)
from dual;
select round(30695.348,-2)
from dual;
select trunc(2.3454,1)
from dual;
5. Divide each employee's salary by 3. Display only those employees?last names and salaries who earn a salary that is a multiple of 3.
----select last_name,salary ,mod(salary,3)
from employees
where mod(salary,3)=0
6. Divide 34 by 8. Show only the remainder of the division. Name the output as EXAMPLE.
----select mod(34,8)as"EXAMPLE"
from dual;
7. How would you like your paycheck -- rounded or truncated? What if your paycheck was calculated to be $565.784 for the week, but you noticed that it was issued for $565.78. The loss of .004 cent would probably make very little difference to you. However, what if this was done to a thousand people, a 100,000 people, or a million people! Would it make a difference then? How much difference?
----I would like my paycheck to be rounded,haha.
0 Comments:
Post a Comment
<< Home