This is my report using UDT data:
I'm displaying a summary of workout data for my blackbelt test. I enter in the date and amounts for that day and then display a summary including the Average # done each day, the Sum Total of each field and the Target number I need to do in order to reach my goals by the specified time. If you just want to display the Top 5 values, then you wouldn't need to create the temp table, you would just run your query.
SELECT CAST(CAST(d1.FieldValue As nvarchar(50)) AS DateTime) AS [Date], CAST(CAST(d2.FieldValue As nvarchar(4)) AS int) AS [Pushups], CAST(CAST(d3.FieldValue As nvarchar(4)) AS int) AS [Crunches], CAST(CAST(d4.FieldValue As nvarchar(4)) AS float) AS [Miles]
INTO #UBBTDetail
FROM UserDefinedData d1
INNER JOIN UserDefinedFields f1 ON d1.UserDefinedFieldId = f1.UserDefinedFieldId
INNER JOIN UserDefinedData d2 ON d1.UserDefinedRowId = d2.UserDefinedRowId
INNER JOIN UserDefinedFields f2 ON d2.UserDefinedFieldId = f2.UserDefinedFieldId
INNER JOIN UserDefinedData d3 ON d1.UserDefinedRowId = d3.UserDefinedRowId
INNER JOIN UserDefinedFields f3 ON d3.UserDefinedFieldId = f3.UserDefinedFieldId
INNER JOIN UserDefinedData d4 ON d1.UserDefinedRowId = d4.UserDefinedRowId
INNER JOIN UserDefinedFields f4 ON d4.UserDefinedFieldId = f4.UserDefinedFieldId
WHERE f1.[ModuleId] = 506
AND f1.FieldTitle = 'Date'
AND f2.FieldTitle = 'Pushups'
AND f3.FieldTitle = 'Crunches'
AND f4.FieldTitle = 'Miles'
SELECT 'SUM' AS Detail, DateDiff(day,MIN([Date]), Max([Date])) As [Days], SUM([Pushups]) As [Pushups], SUM([Crunches]) As [Crunches], SUM([Miles]) As [Miles]
FROM #UBBTDetail Data
UNION
SELECT 'AVG' AS Detail, DateDiff(day,MIN([Date]), Max([Date])) As [Days], AVG([Pushups]) As [Pushups], AVG([Crunches]) As [Crunches], ROUND(AVG([Miles]), 2) As [Miles]
FROM #UBBTDetail Data
UNION
SELECT 'TARGET' AS Detail, DateDiff(day,MAX([Date]), '10/1/2008') As [Days], ROUND((52000 - SUM([Pushups])) / DateDiff(day,MAX([Date]), '10/1/2008'), 0) As [Pushups], ROUND((52000 - SUM([Crunches])) / DateDiff(day,MAX([Date]), '10/1/2008'), 0) As [Crunches], ROUND((1000 - SUM([Miles])) / DateDiff(day,MAX([Date]), '10/1/2008'), 2) As [Miles]
FROM #UBBTDetail Data
DROP TABLE #UBBTDetail