PIVOT を使用する必要があります .次のクエリのようなものが役に立ちます。
SELECT CustomerNumber, CASE WHEN [1] > 0 THEN 'Y' ELSE 'N' END [Sony], CASE WHEN [2] > 0 THEN 'Y' ELSE 'N' END [LG], CASE WHEN [3] > 0 THEN 'Y' ELSE 'N' END [Samsung] FROM (SELECT Product1, CustomerNumber FROM Table) AS SourceTable PIVOT ( COUNT(Product1) FOR Product1 IN ([1], [2], [3]) ) AS PivotTable;
プレ>