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

How to pull certain records from a recordset

Status
Not open for further replies.

SpyderMan1234

IS-IT--Management
Feb 26, 2004
35
US
I have a recordset that looks something like this:

CISKEY DescCD

MLE6456 32
MLE6456 32
JBH1123 10
JBH1123 10
JBH1123 32
JAD5546 10
JAD5546 10

What I need is a way to go through the recordset and for each grouping of CISKEYs if any group has only a 32 and no 10s I need to print that CISKEY. For example, using the above data, the output would be MLE6456. Does anyone have any ideas on how to produce this? Any help is appreciated!!

Thanks

Jeff
 
Brute force method:
SELECT DISTINCT CISKEY FROM yourTable
WHERE DescCD=32 AND CISKEY Not In
(SELECT CISKEY FROM yourTable WHERE DescCD=10)
;
has only a 32
SELECT CISKEY FROM yourTable
WHERE DescCD=32 AND CISKEY Not In
(SELECT CISKEY FROM yourTable WHERE DescCD=10)
GROUP BY CISKEY HAVING Count(*)=1
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks, I think that is what I'm looking for. I can see now that I need to learn more about SQL!

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top