I know that many of you have observed this behavior, but I wonder if anyone can explain why. When I create a small table to create an example of using the rotation function, I get the results that I would expect:
CREATE TABLE dbo.AverageFishLength ( Fishtype VARCHAR(50) , AvgLength DECIMAL(8, 2) , FishAge_Years INT ) INSERT INTO dbo.AverageFishLength ( Fishtype, AvgLength, FishAge_Years ) VALUES ( 'Muskie', 32.75, 3 ), ( 'Muskie', 37.5, 4 ), ( 'Muskie', 39.75, 5 ), ( 'Walleye', 16.5, 3 ), ( 'Walleye', 18.25, 4 ), ( 'Walleye', 20.0, 5 ), ( 'Northern Pike', 20.75, 3 ), ( 'Northern Pike', 23.25, 4 ), ( 'Northern Pike', 26.0, 5 );
Here is a summary request:
SELECT Fishtype , [3] AS [3 Years Old] , [4] AS [4 Years Old] , [5] AS [5 Years Old] FROM dbo.AverageFishLength PIVOT( SUM(AvgLength) FOR FishAge_Years IN ( [3], [4], [5] ) ) AS PivotTbl
Here are the results:

However, if I create a table with an identifier column, the results will be split into separate rows:
DROP TABLE dbo.AverageFishLength CREATE TABLE dbo.AverageFishLength ( ID INT IDENTITY(1,1) , Fishtype VARCHAR(50) , AvgLength DECIMAL(8, 2) , FishAge_Years INT ) INSERT INTO dbo.AverageFishLength ( Fishtype, AvgLength, FishAge_Years ) VALUES ( 'Muskie', 32.75, 3 ), ( 'Muskie', 37.5, 4 ), ( 'Muskie', 39.75, 5 ), ( 'Walleye', 16.5, 3 ), ( 'Walleye', 18.25, 4 ), ( 'Walleye', 20.0, 5 ), ( 'Northern Pike', 20.75, 3 ), ( 'Northern Pike', 23.25, 4 ), ( 'Northern Pike', 26.0, 5 );
Exact exact request:
SELECT Fishtype , [3] AS [3 Years Old] , [4] AS [4 Years Old] , [5] AS [5 Years Old] FROM dbo.AverageFishLength PIVOT( SUM(AvgLength) FOR FishAge_Years IN ( [3], [4], [5] ) ) AS PivotTbl
Various results:

It seems to me that the identifier column is used in the request, although it does not appear at all in the request. This is almost like implicit inclusion in a query, but not shown in the result set.
Can someone explain why this is happening?