Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL MINUS

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I am trying to build a report from a SQL statement. Here is the Statement:
SELECT DONA_IDNO, I_LAST_NAME, I_FIRST_NAME
FROM DONATIONS, INDV
WHERE DONA_IDNO = I_NUMBER
AND DONA_CODE =ANY('P25','P100','P500','P1K')
AND DONA_DATE >= '01-SEP-00'
MINUS
SELECT DONA_IDNO, I_LAST_NAME, I_FIRST_NAME
FROM DONATIONS, INDV
WHERE DONA_IDNO = I_NUMBER
AND DONA_CODE =ANY('P25','P100','P500','P1K')
AND DONA_DATE < '01-SEP-00'
/
The problem is with the key-word MINUS (Not Including). I want to get the first select statement minus the records included in the second select statement. How can this be done within crystal?
 
Are you using Crystal SQL Designer to
build this query?

What is the DBMS?

Cheers,
- Ido

ixm7@psu.edu
 
You don't get what you don't ask for. There's no need for the MINUS Select statement. MINUS is not a SQL reserved word that I am aware of.

Secondly, standard SQL is IN ('A', 'B', 'C') .... not ANY
 
balves,

Actually it depends on the DBMS.
ORACLE handles both MINUS and ANY operators.

Cheers,
- Ido ixm7@psu.edu
 
You're right. MINUS works in Oracle. It's not part of ANSI SQL, so I would try to avoid it. The ODBC driver may do weird things with it.

For example, in SQL Server:

SELECT * FROM TABLE A
MINUS
SELECT * FROM TABLE A WHERE ...

In this case, MINUS is not a reserved word, so it becomes a table alias for TABLE A.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top