TRANSFORM Avg(CASE WHEN [temp].[sumUnits] > 0
THEN [temp].[SumAvgRent] / [temp].[sumUnits]
ELSE 0
END) AS Expr1
SELECT [temp].[Description]
FROM [temp]
GROUP BY [temp].[Description]
PIVOT [temp].[Period];
Need to convert this query for sql server
I have read all other posts but unable to convert this into the same
Here is the equivalent version using the
PIVOTtable operator:SQL Fiddle Demo
For instance, this will give you:
Note that When using the MS SQL Server
PIVOTtable operator, you have to enter the values for the pivoted column. However, IN MS Access, This was the work thatTRANSFORMwithPIVOTdo, which is getting the values of the pivoted column dynamically. In this case you have to do this dynamically with thePIVOToperator, like so:Updated SQL Fiddle Demo
This should give you the same result: