Collections:
Filter Out Duplications in Returning Rows in Oracle
How To Filter Out Duplications in Returning Rows in Oracle?
✍: FYIcenter.com
If there are duplications in the returning rows, and you want to remove the duplications, you can use the keyword DISTINCT or UNIQUE in the SELECT clause. The tutorial exercise below shows you that DISTINCT works on selected columns only:
SQL> CREATE TABLE fyi_team AS
SELECT first_name, last_name FROM employees
WHERE first_name = 'John';
Table created.
SQL> INSERT INTO fyi_team VALUES ('John', 'Chen');
SQL> INSERT INTO fyi_team VALUES ('James', 'Chen');
SQL> INSERT INTO fyi_team VALUES ('Peter', 'Chen');
SQL> INSERT INTO fyi_team VALUES ('John', 'Chen');
SQL> SELECT * FROM fyi_team;
FIRST_NAME LAST_NAME
-------------------- -------------------------
John Chen
John Russell
John Seo
John Chen
James Chen
Peter Chen
John Chen
SQL> SELECT DISTINCT * FROM fyi_team;
FIRST_NAME LAST_NAME
-------------------- -------------------------
Peter Chen
John Chen
James Chen
John Seo
John Russell
SQL> SELECT DISTINCT last_name FROM fyi_team;
LAST_NAME
-------------------------
Chen
Russell
Seo
⇒ What Are Group Functions in Oracle
⇐ Use of SELECT Statements in Views in Oracle
2019-12-19, 2423🔥, 0💬
Popular Posts:
How To List All Login Names on the Server in SQL Server? If you want to see a list of all login name...
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, y...
What To Do If the StartDB.bat Failed to Start the XE Instance in Oracle? If StartDB.bat failed to st...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...
How To Start MySQL Server in MySQL? If you want to start the MySQL server, you can run the "mysqld" ...