The following is example SQL to create a pie chart that displays a report showing the overall state of applications. To display a pie chart, the SQL must limit the result set to 20 rows or less.
SELECT st.StateName, COUNT(*) NumApplications FROM ( SELECT applicationId, Min(TRIM(COALESCE((CASE WHEN COALESCE(DaemonGroupAggStateCode,0) > COALESCE(DatabaseAggStateCode,0) THEN DaemonGroupAggStateCode ELSE DatabaseAggStateCode END),10)) ) AS stateCode FROM MSMApplication GROUP BY 1 ) ast INNER JOIN MSMState st ON st.StateCode=ast.StateCode GROUP BY st.StateName
The Report Viewer portlet displays the following pie chart.