How can i group the data returned by statement below by "Dept" field. I have already tried to group it like shown below but that doesn't seem to work for me. Any help.
cmd_select =
New SqlCommand("SELECT Incident_id,Dept From Report_Incident Group By Dept,Incident_id", myconnection_string)Try using ORDER BY instead of GROUP BY in the SQL. That should work.
|||Ok thanks ORDER BY should work but the problem is that i want to display the returned data visually in a pie chart. Eg if i have three departments(Dept) in Administratio, Engineering and Production, then my chart should only show those three not to show the dept for each and every record. So basically i want to group the piechart slices by dept.|||Ok i got it. The code below now does my work.
cmd_select =New SqlCommand("SELECT COUNT(incident_id)AS total ,Dept,incident_date From Report_Incident
WHERE incident_date >=@.date1 AND incident_date<=@.date2 GROUP BY dept,incident_date ORDER BY total", myconnection_string)
No comments:
Post a Comment