public void FilterDuplicate()
{
DataTable dt = new DataTable("person");
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("age", typeof(string));
dt.Columns.Add("sex", typeof(string));
dt.Rows.Add("张三", "28", "男");
dt.Rows.Add("李四", "28", "男");
dt.Rows.Add("张三", "28", "男");
string[] distinctcols = new string[(dt.Columns.Count)];
foreach (DataColumn dc in dt.Columns)
{
distinctcols[dc.Ordinal] = dc.ColumnName;
}
DataTable dtqc = new DataTable("person1");
DataView dataview = new DataView(dt);
dtqc = dataview.ToTable(true, distinctcols);
}
随便写的,看符合你的情况吗;dt是未去重,dtqc是去重后的
select sum(A) as A,sum(B) as B ,sum(C) as C,sum(D) as D from gz
我这边没有装数据库, 你试试可不可以...看错题目了....等下我再想想....
这样:
select gz,sum(A) as 'A',sum(B) as 'B',sum(C) as 'C',sum(D) as 'D' from test group by gz