• SqlSugar 笔记


    分组:

    日期分组一:

    var result = await temp
                    .GroupBy("date_format(Day,'%Y-%m')")
                    .Select(s => new ViewModel.Managerment.MemberAmountChartView()
                    {
                        Month = SqlFunc.MappingColumn(s.Day, "date_format(Day,'%Y-%m')"),
                        TotalMember = SqlFunc.AggregateSum(s.IsMember) + SqlFunc.AggregateSum(s.NotMember),
                        IsMember = SqlFunc.AggregateSum(s.IsMember),
                        NotMember = SqlFunc.AggregateSum(s.NotMember)
                    }).ToListAsync();

    日期分组二:

                            temp = temp.GroupBy(s => SqlFunc.DateValue(s.Date, DateType.Year))
                                .GroupBy(s => SqlFunc.DateValue(s.Date, DateType.Month));
                            var result = await temp.Select(s => new
                            {
                                CollectAmount = SqlFunc.AggregateSum(s.CollectAmount),
                                Year = SqlFunc.DateValue(s.Date, DateType.Year),
                                Month = SqlFunc.DateValue(s.Date, DateType.Month)
                            }).ToListAsync();
                            eChatsRes.X = result.Select(s => $"{s.Year}-{s.Month}").ToList();
                            eChatsRes.Y = result.Select(s => s.CollectAmount).ToList();
  • 相关阅读:
    NYOJ 734
    NYOJ 762
    NYOJ 743
    NYOJ 478
    NYOJ 451
    NYOJ 461
    NYOJ 485
    NYOJ 333
    平均互信息
    ASCII码
  • 原文地址:https://www.cnblogs.com/Celebrator/p/11345027.html
Copyright © 2020-2023  润新知