Sunday 18 September 2011

EXAMPLES


WORKSHEET – A

Display the names of all employees where the third letter name is an A.

SQL> select * from emp where ename like '__A%';

      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM   DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------------

       7698 BLAKE      MANAGER         7839 01-MAY-81       2850                  30
                                                                             
       7782 CLARK      MANAGER         7839 09-JUN-81       2450                  10
                                                                             
       7876 ADAMS      CLERK           7788 23-MAY-87       1100                  20



Display the name of all employee that have two ‘L’ in their name and are in
   department 30 or their manager is 7782.


SQL> select * from emp where ename like '%L%L%' and (deptno=30 or mgr=7782);

      EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM   DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------------
                                                                   
       7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300       30

       7934 MILLER     CLERK           7782 23-JAN-82       1300                  10


Display the name, job and salary for all employee whose job is clerk or analyst and their salary is not equal to $1000,$3000, or $5000.
 

SQL> select ename,job,sal from emp where (job='CLERK' or job='ANALYST') and sal not in(1000,3000,5000);

         
ENAME      JOB         SAL                                              
---------- --------- ----------                                              
SMITH      CLERK        800                                              
ADAMS      CLERK       1100                                              
JAMES      CLERK        950                                              
MILLER     CLERK       1300    

0 comments:

Post a Comment