Dear Experts,
I would want to join the table in a dataset ds and then do a group by on several variables. the below is the code i have attempted.
Antony
Dim ct As DataTable = ds.Tables("ctime")
Dim phh As DataTable = ds.Tables("perhour")
Dim area As DataTable = ds.Tables("areas")
Dim bs As DataTable = ds.Tables("station")
Dim query = From hh In phh.AsEnumerable() Join t In ct.AsEnumerable() _
On t.Field(Of Integer)("time_key") Equals hh.Field(Of Integer)("time_key") _
Join ar In area.AsEnumerable() _
On hh.Field(Of Integer)("wallet_cd") Equals ar.Field(Of Integer)("wallet_cd") _
Join b In bs.AsEnumerable() _
On hh.Field(Of Integer)("base_station_key") Equals b.Field(Of Integer)("base_station_key") _
Group hh By customerid = hh.Field(Of Integer)("msisdn") Into grp = Group _
Select New With _
{ _
Key customerid, _
.rev_dat_tot_nbn = grp.Sum(Function(x) If(x.Field(Of String)("usage_type_key") = 44, x.Field(Of Decimal)("call_cost_amt"), 0)),
.rev_voi_tot_nbn = grp.Sum(Function(x) If(x.Field(Of String)("usage_type_key") = 41, x.Field(Of Decimal)("call_cost_amt"), 0)),
.rev_sms_tot_nbn = grp.Sum(Function(x) If(x.Field(Of String)("usage_type_key") = 42, x.Field(Of Decimal)("call_cost_amt"), 0)),
.rev_tot_tot_nbn = grp.Sum(Function(x) x.Field(Of Decimal)("call_cost_amt")) _
}
ASKER
This looks to work. Now help me put more than one group by variable. I want to include datekey into the group by variables