Hi,
you can first make the
Scalar valued function
which returns the count.
CREATE FUNCTION fn_GetPhoneCount
(
@Phone_No nvarchar(50) = ''
)
RETURNS int
AS
BEGIN
Declare @Cnt INT
SET @Cnt = 0
Select @Cnt = COUNT(*) from Table_1 where Phone_No = @Phone_No
Return @Cnt
END
Then write the query like this.
Select [ID], [Name], [Phone_No], dbo.fn_GetPhoneCount([Phone_No]) AS [Count] from Table_1
I hope this will help you to get your answer.