Try:
SELECT COUNT(*) AS InGroup FROM student WHERE GroupID=2
"can you give me a much clear code that i should do in the button instead of just this one line?it will be really helpful to me, thank"
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand com = new SqlCommand("SELECT COUNT(*) AS InGroup FROM student WHERE GroupID=2", con))
{
int count = com.ExecuteScalar())
...
}
}