Click here to Skip to main content
15,895,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have table like this

**MobileNO service**
111111 abc
111111 def
111111 ghi
111111 jkm
222222 abc
222222 def
333333 ghi
333333 jkm

i want to select mobile number who exist in abc service but not relate in other service

example
222222 mobile number exist in sigle service so i found this
Posted
Comments
Mehdi Gholam 9-Apr-15 10:31am    
222222 exists in 2 services in your data.

1 solution

Something like this?
SQL
SELECT
    MobileNo
FROM
    YourTable As T
WHERE
    Service = 'abc'
And
    Not Exists
    (
        SELECT 1
        FROM YourTable As T2
        WHERE T2.MobileNo = T.MobileNo
        And T2.Service != 'abc'
    )
;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900