Compare Date type value : Logical Operators « Select Query « Oracle PL / SQL






Compare Date type value

  
SQL>
SQL> CREATE TABLE purchase (
  2       product_name  VARCHAR2(25),
  3       quantity      NUMBER(4,2),
  4       purchase_date DATE,
  5       salesperson   VARCHAR2(3)
  6       );

Table created.

SQL>
SQL> INSERT INTO purchase VALUES ('A',   1,  '14-JUL-03', 'CA');

1 row created.

SQL> INSERT INTO purchase VALUES ('B',   75, '14-JUL-03', 'BB');

1 row created.

SQL> INSERT INTO purchase VALUES ('C',   2,  '14-JUL-03', 'GA');

1 row created.

SQL> INSERT INTO purchase VALUES ('D',   8,  '15-JUL-03', 'GA');

1 row created.

SQL> INSERT INTO purchase VALUES ('A',   20, '15-JUL-03', 'LB');

1 row created.

SQL> INSERT INTO purchase VALUES ('B',   2,  '16-JUL-03', 'CA');

1 row created.

SQL> INSERT INTO purchase VALUES ('C',   25, '16-JUL-03', 'LB');

1 row created.

SQL> INSERT INTO purchase VALUES ('D',   2,  '17-JUL-03', 'BB');

1 row created.

SQL>
SQL> SELECT * FROM purchase;

PRODUCT_NAME                QUANTITY PURCHASE_ SAL
------------------------- ---------- --------- ---
A                                  1 14-JUL-03 CA
B                                 75 14-JUL-03 BB
C                                  2 14-JUL-03 GA
D                                  8 15-JUL-03 GA
A                                 20 15-JUL-03 LB
B                                  2 16-JUL-03 CA
C                                 25 16-JUL-03 LB
D                                  2 17-JUL-03 BB

8 rows selected.

SQL>
SQL> DELETE FROM purchase
  2  WHERE purchase_date > '15-JUL-03';

3 rows deleted.

SQL>
SQL> SELECT * FROM purchase;

PRODUCT_NAME                QUANTITY PURCHASE_ SAL
------------------------- ---------- --------- ---
A                                  1 14-JUL-03 CA
B                                 75 14-JUL-03 BB
C                                  2 14-JUL-03 GA
D                                  8 15-JUL-03 GA
A                                 20 15-JUL-03 LB

5 rows selected.

SQL>
SQL> DROP TABLE purchase;

Table dropped.

SQL>

   
  








Related examples in the same category

1.Demo for Order of Precedence for Logical Operators
2.compare varchar type value in where clause
3.Not(condition1 and condition2)