CREATE TABLE #TblX( Code varchar(20)) DECLARE @TblY TABLE(Code varchar(20)) INSERT #TblX SELECT distinct Code FROM tbl_MainList SELECT feorcre,ClientID,[#TblX] FROM (SELECT distinct Code,feorcre,ClientID FROM tbl_MainList where FeorCRE=@FeorCre ) As Souce PIVOT (COUNT(Code) FOR Code IN ([#TblX])) As p
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)