INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Query records for only selected criteria

Query records for only selected criteria

(OP)
I have one table with all available funding agencies. I also have a contracts table. I could have one contract with funding from multiple agencies such as 607, 207 or 307. What I need to find is which contracts are being funded ONLY by agency 207. How would I write this?

Thanks,
Sherry

RE: Query records for only selected criteria

"I could have one contract with funding from multiple agencies" - could you show an example of how that looks like in your table: one contract, multiple agencies?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Query records for only selected criteria

(OP)
In this example, I have 3 contracts/projects. The first one has 3 funding sources (Agcy 2207, 2307 & 6207), the second one has only one funding source (Agcy 2207), the third has 2 funding sources (Agcy 2207, 2307). I only want the contract/projects with Agcy 2207 or 2307 (SPID 238.001 & 294.001) I don't want 136.001 since it includes Agcy 6207.

CODE

SPID    FUND AGCY ORG   CONTRACT_NAME
136.001	3880 2207 0993	Chicon St.
136.001	4390 2307 0894	Chicon St.
136.001	8250 6207 2038	Chicon St.

238.001	3880 2207 0762	Water System Imprs.

294.001	3880 2207 0944	Loop 275
294.001	4390 2307 0944	Loop 275 

thanks,
Sherry

RE: Query records for only selected criteria

Sherry,

Your specifications seem a bit contradictory to me:
  • What I need to find is which contracts are being funded ONLY by agency 207.
  • I only want the contract/projects with Agcy 2207 or 2307.
Could you please disambiguate your specs for me?

santaMufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel."

RE: Query records for only selected criteria

How about:

SELECT SPID FROM MyTable
WHERE AGCY IN (2207, 2307)
MINUS
SELECT SPID FROM MyTable
WHERE AGCY NOT IN (2207, 2307)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

RE: Query records for only selected criteria

(OP)
Thanks, but I got it.

RE: Query records for only selected criteria

Did my sollution work for you? Or am I way off? Or you came up with your own - if so: what did you do?
It would be nice to share it for the benefit to others.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close