|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| PL/SQL Querries ,Stored
Procedures,Views |
|
|
|
|
|
|
|
|
|
|
| Using
the where Clause :: |
| Select ename,
job from emp where job = 'clerk'; |
|
| ENAME |
JOB |
| JAMES |
CLERK |
| ADAMS |
CLERK |
| SMITH |
CLERK |
| MILLER |
CLERK |
|
|
|
|
|
|
|
|
|
|
| Using
the comparison Operator |
| Select ename,
sal , comm from emp where sal <= comm; |
| |
|
| ENAME |
SAL |
| MARTIN |
1250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Using
the Between Operator : |
| Select ename
, sal from emp where sal BETWEEN 1000 AND
1500 |
| |
|
| ENAME |
SAL |
| ADAMS |
1100 |
| MARTIN |
1250 |
| TURNER |
1500 |
| WARD |
1250 |
|
|
|
|
|
|
|
|
|
|
| Using
the LIKE Operator : |
| Select ename form emp where
ename LIKE 'S%' |
| The % or _ symbols can be
used in any combination with literal characters. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Using
the AND Operator : |
| Select empno , ename ,job
,sal from emp where sal >=1100 OR job = 'Clerk'; |
| In this example , either
condition can be true for any record to be selected .Therefore,
an employee who has a job title of CLERK or earns more than $1100
will be selected . |
|
|
|
|
|
|
|
|
|
|
| Rules
of Precedence : |
Select ename,job,sal
from emp where (job='salesman' OR job=
'President') AND sal >1500; |
| In the example,there are
two conditions: The first condition is that
job is President or Salesman.The second condition
is that salaray is greater than 1500.Therefore,
the select statement reads as follows. |
| Select the row if an employee
is a president or a salesman and if the employeeearns more than $1500. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Order
by Clause : |
| Select ename ,job, dept
no , hiredate from emp Order By hiredate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Sorting
in Descending Order : |
| Select ename , job ,deptno, hiredate from
emp ORDER BY hiredate DESC. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|