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

Query records for only selected criteria

Status
Not open for further replies.

szeiss

Programmer
Apr 5, 2000
137
US
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
 
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.
 
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
 
Sherry,

Your specifications seem a bit contradictory to me:[ul][li]What I need to find is which contracts are being funded ONLY by agency 207.[/li]
[li]I only want the contract/projects with Agcy 2207 or 2307.[/li][/ul]

Could you please disambiguate your specs for me?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
How about:
[tt]
SELECT SPID FROM MyTable
WHERE AGCY IN (2207, 2307)
MINUS
SELECT SPID FROM MyTable
WHERE AGCY NOT IN (2207, 2307)
[/tt]


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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top