Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT P.Id AS PhoneNumberId
- ,M.PersonId
- ,D.Value AS PhoneNumber
- ,M.count_of_type
- ,P.Number
- ,P.Extension
- FROM (
- SELECT personid
- ,NumberTypeValueId
- ,count(id) AS [count_of_type]
- FROM [dbo].[PhoneNumber]
- GROUP BY personid
- ,NumberTypeValueId
- HAVING count(id) > 0
- ) M
- JOIN DefinedValue D ON D.Id = M.NumberTypeValueId
- JOIN PhoneNumber P ON P.PersonId = M.PersonId
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement