I need a majic potion to make the integer values returned of percentages ALWAYS add to 100.SELECT Answer , Total , '<img src="bar.gif" height="15px" width='+ CAST(CAST([Percent] AS INT) AS VARCHAR) + 'px"> ' as ' ', CAST(CAST([Percent] AS INT) AS VARCHAR)+ '%'as ' ' FROM ( SELECT BodyText AS Answer, ST.Choice, IsNull(Total, 0) AS Total, CASE WHEN Total Is NULL THEN 0 ELSE Total * 100.0 / (SELECT COUNT(*) FROM dbo.SurveyResult WHERE Abbr=@Abbr AND CourseID = @CourseID) END AS [Percent] FROM dbo.SurveyText ST LEFT OUTER JOIN (SELECT Abbr, Choice, Count(*) AS Total -- Count up the Survey Results for this question FROM dbo.SurveyResult WHERE Abbr = @Abbr AND CourseID = @CourseID GROUP BY Abbr, Choice ) SR ON ST.Abbr = SR.Abbr AND ST.Choice = SR.Choice WHERE Language = @Language AND ST.Abbr = @Abbr AND CourseID = @CourseID AND ST.Choice > 0 ) X ORDER BY Choice
I've posted the whole taco here, along with the guacamole.Problem is one of rounding. If every row is rounded down, then it'll probably add up to 99% if all the percentages are added.If every row is rounded up, then it'll probably add up to 101%.Any ideas?Sam