Oracle 19c SQL

  1. Home
  2. Docs
  3. Oracle 19c SQL
  4. 6 SET Operators
  5. 6.5 MINUS

6.5 MINUS

Minus operator displays the rows which are present in the first query but absent in the second query, with no duplicates and data arranged in ascending order by default.

--1st query
SELECT Ename FROM Emp WHERE Deptno = 20;

ENAME
----------
JONES
SCOTT
FORD
SMITH
ADAMS


--2nd query
SELECT Ename FROM Emp WHERE Job = 'CLERK';

ENAME
----------
SMITH
ADAMS
JAMES
MILLER
SELECT Ename FROM Emp WHERE Deptno = 20
MINUS
SELECT Ename FROM Emp WHERE Job = 'CLERK';

ENAME
----------
FORD
JONES
SCOTT


SELECT Ename FROM Emp WHERE Job = 'CLERK'
MINUS
SELECT Ename FROM Emp WHERE Deptno = 20;

ENAME
----------
JAMES
MILLER
Was this article helpful to you? Yes No

How can we help?