user1024050
user1024050

Reputation: 3

SQL Server 2008 query for members who meet multiple conditions

I searched for this and found similar queries, but none that gave the specific results I am seeking.

I have a table of all phone numbers called. I need a list of ALL OrigNumber who dialed EACH of three different TermNumber.

I tried:

SELECT OrigNumber FROM tbl_DetailCalls
WHERE (TermNumber='2463332121' AND TermNumber='2463334920' AND TermNumber='2463339901')
GROUP BY OrigNumber

I only need one instance of each OrigNumber that meets the condition.

Thanks!

Upvotes: 0

Views: 459

Answers (1)

Stuart Ainsworth
Stuart Ainsworth

Reputation: 12940

Select orignumber
From tbl_DetailCalls
Where termnumber in ('2463332121', '2463334920', '2463339901')
Group by orignumber
Having count(distinct termnumber)>=3

Sorry for format. Sent from phone.

Upvotes: 2

Related Questions