Hi,
Check the below Code....
DECLARE @Cat TABLE(CatID INT, CatDesc VARCHAR(200))
DECLARE @TranDtls TABLE (CatID INT, PostCount INT)
INSERT INTO @Cat(CatID, CatDesc)
SELECT 1, 'Sports'
UNION ALL SELECT 2,'Accounts'
UNION ALL SELECT 3,'IT'
UNION ALL SELECT 4,'General'
INSERT INTO @TranDtls (CatID, PostCount )
SELECT 1,10
UNION ALL SELECT 1,1
UNION ALL SELECT 1,3
UNION ALL SELECT 2,1
UNION ALL SELECT 2,5
UNION ALL SELECT 4,16
SELECT C.CatDesc+'('+CAST(ISNULL(T.PostCount ,0) AS VARCHAR(20))+')' AS Category
FROM @Cat C
LEFT OUTER JOIN (SELECT CatID, SUM(PostCount) 'PostCount' FROM @TranDtls GROUP BY CatID) T ON T.CatID=C.CatID
Regards,
GVPrabu