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->ConnectionString = DataSourceString + DatabaseConnectionString;

	SqlConnection1->Open();
	SqlClient::SqlCommand ^SqlCommand1;
	SqlCommand1 = gcnew SqlClient::SqlCommand();
	SqlCommand1->Connection = SqlConnection1;

	SqlCommand1->CommandType = CommandType::Text;
	SqlCommand1->CommandText = "SELECT TagScore, COUNT(TagScore) FROM tblTagEvents WHERE SomeColumnName='Active' GROUP BY TagScore"
	SqlClient::SqlDataReader ^reader1 = SqlCommand1->ExecuteReader();
	while (reader1->Read())
	{
		Array::Resize(Value, Value->Length + 1);
		Array::Resize(MatchingRows, MatchingRows->Length + 1);
		Value[(Value->Length - 1)] = Convert::ToInt32(reader1[0]);
		MatchingRows[(MatchingRows->Length - 1)] = Convert::ToInt32(reader1[1]);
	}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *