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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting info out from a table 1

Status
Not open for further replies.

skarface06

Technical User
Jul 15, 2003
8
0
0
US
Sorry, Im just a beginner but I was wondering how I could go about selecting the people from month=jun that are not in
month=mar. In this case would be Adam and Eve.

employee table
DATE ID NAME

mar 1 Larry
mar 2 Curly
mar 3 Moe
mar 4 Jack
mar 5 Jill
jun 3 Moe
jun 4 Jack
jun 5 Jill
jun 6 Adam
jun 7 Eve
 
Something like this ?
Select * from employee where date='jun'
and id not in (select id from employee where date='mar')

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
There are numerous ways.
One approach would be
Code:
SELECT id, name 
FROM my_table n1
WHERE date = 'jun'
AND NOT EXISTS (SELECT 'x'
                FROM my_table
                WHERE name = n1.name
                  AND date = 'mar');
If your RDBMS supports the use of MINUS, then you could also use
Code:
SELECT id, name FROM my_table WHERE date = 'jun'
MINUS
SELECT id, name FROM my_table WHERE date = 'mar';

Elbert, CO
1635 MDT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top