PivotTable

SELECT InvoiceNo,isnull([1],'')+','+isnull([2],'')+','+isnull([3],'')+','+isnull([4],'') ActionType
FROM
(
SELECT InvoiceNo,cast(SendType as varchar) ActionType
from dbo.PrintShareEmail SI with (nolock)
where 1=1
--AND UserID=@userid
AND (@type=0 OR SendType=@type )
) g
PIVOT
(
min(ActionType)
FOR ActionType IN ([1], [2], [3], [4])
) AS PivotTable

转载于:https://www.cnblogs.com/zhumr/archive/2013/06/08/3125659.html

你可能感兴趣的:(PivotTable)