MAKE FULL WEB APPLICATION WITH JUST SQL KNOWLEDGE? CLICK HERE
The MINUS query returns all rows in the first query that
are not returned in the second query. Each SQL statement
within the MINUS query must have the same number of fields
in the result sets with similar data types. The MINUS operates
on two SQL statements. If the second SQL statement includes results
not present in the first SQL statement, such results are ignored.
The syntax is as follows :-
[SQL Statement 1]
MINUS
[SQL Statement 2] |
EXAMPLE I :-
Table Store_Information
STORE NAME
|
SALES
|
DATE
|
SU RU
|
$1500
|
Jan-05-2006
|
THE TREND
|
$250
|
Jan-07-2006
|
POSITIVE
|
$300
|
Jan-08-2006
|
THE TREND
|
$700
|
Jan-08-2006
|
Table Internet Sales
DATE
|
SALES
|
Jan-07-2006
|
$250
|
Jan-10-2006
|
$535
|
Jan-11-2006
|
$320
|
Jan-12-2006
|
$750
|
We want to find out all the dates where there are store
sales, but no internet sales.
We use the following SQL statement :-
SELECT Date FROM Store_Information
MINUS
SELECT Date FROM Internet_Sales |
RESULT:-
DATE
|
Jan-05-2006
|
Jan-08-2006
|
If you don't find what you are looking for. Please click
here to submit your query, our experts will reply soon.
|