Practice3 - Practice 3 SQL 1. Write a query to display the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Practice 3 – SQL 1. Write a query to display the current date. Label this column Date. SQL> select sysdate "Date" 2 from dual; Date --------- 14-JAN-12 2. Display the employee number, name, salary, salary increase by 15% expressed as a whole number. Label the column New Salary. Save your SQL statement to a file named p3q2.sql SQL>ed/ SQL> select empno, ename, sal, round((sal+sal*0.15),0) "New Salary" 2 from emp; EMPNO ENAME SAL New Salary ---------- ---------- ---------- ---------- 7369 SMITH 800 920 7499 ALLEN 1600 1840 7521 WARD 1250 1438 7566 JONES 2975 3421 7654 MARTIN 1250 1438 7698 BLAKE 2850 3278 7782 CLARK 2450 2818 7788 SCOTT 3000 3450 7839 KING 5000 5750 7844 TURNER 1500 1725 7876 ADAMS 1100 1265 EMPNO ENAME SAL New Salary ---------- ---------- ---------- ---------- 7900 JAMES 950 1093 7902 FORD 3000 3450 7934 MILLER 1300 1495 14 rows selected. SQL>/ File saved 3. Run the query in the file p3q2.sql SQL> edit
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Wrote file afiedt.buf 1 select empno, ename, sal, round((sal+sal*0.15),0) "New Salary" 2* from emp SQL> / EMPNO ENAME SAL New Salary ---------- ---------- ---------- ---------- 7369 SMITH 800 920 7499 ALLEN 1600 1840 7521 WARD 1250 1438 7566 JONES 2975 3421 7654 MARTIN 1250 1438 7698 BLAKE 2850 3278 7782 CLARK 2450 2818 7788 SCOTT 3000 3450 7839 KING 5000 5750 7844 TURNER 1500 1725 7876 ADAMS 1100 1265 EMPNO ENAME SAL New Salary ---------- ---------- ---------- ---------- 7900 JAMES 950 1093 7902 FORD 3000 3450 7934 MILLER 1300 1495 14 rows selected. 4. Modify your query p3q2.sql to add an additional column that will subtract the old salary from the new salary. Label the column Increase. Rerun your query. SQL> edit Wrote file afiedt.buf 1 select empno, ename, sal, round((sal+sal*0.15),0) "New Salary", 2 round((sal+sal*0.15),0) - sal "Difference" 3* from emp SQL> / EMPNO ENAME SAL New Salary Difference ---------- ---------- ---------- ---------- ---------- 7369 SMITH 800 920 120 7499 ALLEN 1600 1840 240 7521 WARD 1250 1438 188 7566 JONES 2975 3421 446 7654 MARTIN 1250 1438 188
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/29/2012 for the course INTERNATIO 101 taught by Professor Mr.johnnash during the Spring '11 term at Symbiosis International University.

Page1 / 7

Practice3 - Practice 3 SQL 1. Write a query to display the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online