DataTable dt= dbhelp.Query(sql).Tables[0]; IEnumerable<IGrouping<string, DataRow>> result = dt.Rows.Cast<DataRow>().GroupBy<DataRow, string>(dr => dr["A"].ToString());//按A分組 foreach (IGrouping<string, DataRow> ig in result) { string s = ig.Key; A int i= ig.Count(); A類型筆數 }