BETWEEN
SQL RANGE used to display rows based on a rang of values,you use the between and keywords .
You specify the between keyword followed by the lower limit of the range, and keyword, and the higher limit of the range.
For example
SELECT EMPNO,ENAME,SAL
FROM EMP
WHERE SAL BETWEEN 1600 AND 3000;
EMPNO ENAME SAL
--------- ---------- ----------
7499 ALLEN 1600
7566 JONES 2975
7698 BLAKE 2850
7782 CLARK 2450
7788 SCOTT 3000
7902 FORD 3000
WHEN YOU USE THE CHARACTER OR DATE VALUES WITH BETWEEN OPERATOR .YOU PLACE EACH VALUE WITHIN SINGLE QUOTATION MARKS.
FOR EXAMPLE
SELECT EMPNO,ENAME,SAL
FROM EMP
WHERE HIREDATE BETWEEN ’02-APR-81’ AND ’17-NOV-81’;
EMPNO ENAME SAL
--------- ---------- ----------
7566 JONES 2975
7654 MARTIN 1250
7698 BLAKE 2850
7782 CLARK 2450
7839 KING 5000
7844 TURNER 1500
SELECT ENAME, SAL
FROM EMP
WHERE ENAME BETWEEN ‘A’ AND ‘S’;
ENAME SAL
---------- ----------
ALLEN 1600
JONES 2975
MARTIN 1250
BLAKE 2850
CLARK 2450
KING 5000
ADAMS 1100
JAMES 950
FORD 3000
MILLER 1300
No comments:
Post a Comment