UNIQUE / DISTINCT
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 UNIQUE product_name
2 FROM purchase
3 ORDER BY product_name;
PRODUCT_NAME
-------------------------
A
B
C
D
4 rows selected.
SQL>
SQL> SELECT Distinct product_name
2 FROM purchase
3 ORDER BY product_name;
PRODUCT_NAME
-------------------------
A
B
C
D
4 rows selected.
SQL>
SQL>
SQL> DROP TABLE purchase;
Table dropped.
SQL>
Related examples in the same category