Query Spec, version 5.9.6 Sql Server
Online documentation says:
Max Calculates the max value for field MAX(field) Works on numeric fields (decimal / int / float / byte / etc.) only
For me seems to work on other column types like string. I haven't tested date yet but I hope it works.
This may be true for Min as well, I haven't tested.
var query = qf.SubscriberChurnDetail
.Select(()=>new SubscriberChurnSummaryModel
{
CustomerId = SubscriberChurnDetailFields.CustomerId.ToValue<int>(),
CustomerCode = **SubscriberChurnDetailFields.CustomerCode.SetAggregateFunction(AggregateFunction.Max)
.ToValue<string>(),**
SacId = SubscriberChurnDetailFields.SacId.ToValue<int>(),
Sac = SubscriberChurnDetailFields.Sac.ToValue<string>(),
State = SubscriberChurnDetailFields.State.ToValue<string>(),
StartPeriodId = SubscriberChurnDetailFields.StartPeriodId.ToValue<int?>(),
StartPeriod = SubscriberChurnDetailFields.StartPeriod.ToValue<string>(),
StartTransactionTypeId = SubscriberChurnDetailFields.StartTransactionTypeId.ToValue<int?>(),
StartTransactionType = SubscriberChurnDetailFields.StartTransactionType.ToValue<string>(),
EndPeriodId = SubscriberChurnDetailFields.EndPeriodId.ToValue<int?>(),
EndPeriod = SubscriberChurnDetailFields.EndPeriod.ToValue<string>(),
EndTransactionTypeId = SubscriberChurnDetailFields.EndTransactionTypeId.ToValue<int?>(),
EndTransactionType = SubscriberChurnDetailFields.EndTransactionType.ToValue<string>(), //SubscriberCount = Functions.CountRow().ToValue<int>()
SubscriberCount = Functions.CountRow().ToValue<int>()
})
.Where(SubscriberChurnDetailFields.CustomerId==customerIds)
.Where(SubscriberChurnDetailFields.SacId==sacIds)
.Where(SubscriberChurnDetailFields.StartPeriodId==periodIds)
.GroupBy(
SubscriberChurnDetailFields.CustomerId,
//SubscriberChurnDetailFields.CustomerCode,
SubscriberChurnDetailFields.SacId,
SubscriberChurnDetailFields.Sac,
SubscriberChurnDetailFields.State,
SubscriberChurnDetailFields.StartPeriodId,
SubscriberChurnDetailFields.StartPeriod,
SubscriberChurnDetailFields.StartTransactionTypeId,
SubscriberChurnDetailFields.StartTransactionType,
SubscriberChurnDetailFields.EndPeriodId,
SubscriberChurnDetailFields.EndPeriod,
SubscriberChurnDetailFields.EndTransactionTypeId,
SubscriberChurnDetailFields.EndTransactionType
)