{"id":98,"date":"2010-07-23T14:58:46","date_gmt":"2010-07-23T14:58:46","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=98"},"modified":"2022-02-17T07:14:15","modified_gmt":"2022-02-17T07:14:15","slug":"group-by","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/sql-server\/queries-microsoft-sql-server\/select-statements\/group-by","title":{"rendered":"GROUP BY"},"content":{"rendered":"<p>Group By Allows You To Return Results Grouped By A Certain Value Which Rows Share.<\/p>\n<h4>Returns Total Number Of Rows For Each Value Present<\/h4>\n<pre><code>\r\n\tarray ^Value = gcnew array(0);\r\n\tarray ^MatchingRows= gcnew array(0);\r\n\r\n\tSqlClient::SqlConnection ^SqlConnection1 = gcnew SqlClient::SqlConnection();\r\n\tSqlConnection1-&gt;ConnectionString = DataSourceString + DatabaseConnectionString;\r\n\r\n\tSqlConnection1-&gt;Open();\r\n\tSqlClient::SqlCommand ^SqlCommand1;\r\n\tSqlCommand1 = gcnew SqlClient::SqlCommand();\r\n\tSqlCommand1-&gt;Connection = SqlConnection1;\r\n\r\n\tSqlCommand1-&gt;CommandType = CommandType::Text;\r\n\tSqlCommand1-&gt;CommandText = \"SELECT TagScore, COUNT(TagScore) FROM tblTagEvents WHERE SomeColumnName='Active' GROUP BY TagScore\"\r\n\tSqlClient::SqlDataReader ^reader1 = SqlCommand1-&gt;ExecuteReader();\r\n\twhile (reader1-&gt;Read())\r\n\t{\r\n\t\tArray::Resize(Value, Value-&gt;Length + 1);\r\n\t\tArray::Resize(MatchingRows, MatchingRows-&gt;Length + 1);\r\n\t\tValue[(Value-&gt;Length - 1)] = Convert::ToInt32(reader1[0]);\r\n\t\tMatchingRows[(MatchingRows-&gt;Length - 1)] = Convert::ToInt32(reader1[1]);\r\n\t}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Group By Allows You To Return Results Grouped By A Certain Value Which Rows Share. Returns Total Number Of Rows For Each Value Present array ^Value = gcnew array(0); array ^MatchingRows= gcnew array(0); SqlClient::SqlConnection ^SqlConnection1 = gcnew SqlClient::SqlConnection(); SqlConnection1-&gt;ConnectionString = DataSourceString + DatabaseConnectionString; SqlConnection1-&gt;Open(); SqlClient::SqlCommand ^SqlCommand1; SqlCommand1 = gcnew SqlClient::SqlCommand(); SqlCommand1-&gt;Connection = SqlConnection1; SqlCommand1-&gt;CommandType = [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-select-statements"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":1496,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/98\/revisions\/1496"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}