In case you would like to know a linq solution:
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("DAT", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Num", typeof(int)));
dt.Columns.Add(new DataColumn("NAME", typeof(string)));
dt.Columns.Add(new DataColumn("AMOUNT", typeof(double)));
dt.Rows.Add(new object[]{new DateTime(2018,1,1), 1, "JHON", 600.00});
dt.Rows.Add(new object[]{new DateTime(2018,1,1), 2, "JHON", 320.00});
dt.Rows.Add(new object[]{new DateTime(2018,1,1), 3, "FREDY", 20.00});
dt.Rows.Add(new object[]{new DateTime(2018,1,2), 4, "JHON", 32.00});
dt.Rows.Add(new object[]{new DateTime(2018,1,2), 5, "FREDY", 360.00});
dt.Rows.Add(new object[]{new DateTime(2018,1,3), 6, "MARK", 100.00});
dt.Rows.Add(new object[]{new DateTime(2018,1,3), 7, "MARK", 223.00});
var result = dt.AsEnumerable()
.GroupBy(x=>x.Field<DateTime>("DAT"))
.Select(grp=>new
{
DAT = grp.Key.ToString("dd/MM/yyyy"),
AMOUNT = grp.Sum(a=>a.Field<double>("AMOUNT")),
NoOfCust = grp.Count()
});
A
result
variable stores:
DAT AMOUNT NoOfCust
01/01/2018 940 3
02/01/2018 392 2
03/01/2018 323 2