日期:2014-05-20 浏览次数:20838 次
select sum(UserConsumeMoney) as totalMoney, convert(nvarchar(7), ConsumeDay,120) as monthConsume from T_UserConsumeDay where DATEDIFF(MONTH,ConsumeDay,GETDATE())<12 group by convert(nvarchar(7), ConsumeDay,120)
from u in UserConsumeDay group u by u.ConsumeDay into con select new { con.Key, monthConsume = con.Sum(u => u.UserConsumeMoney) }
var result = Database.Set<User>().Where(x => x.CreatedAt >= utcFrom && x.CreatedAt <= utcTo) .GroupBy(x => new { SqlFunctions.DateAdd("hh", offset, x.CreatedAt).Value.Year, SqlFunctions.DateAdd("hh", offset, x.CreatedAt).Value.Month, SqlFunctions.DateAdd("hh", offset, x.CreatedAt).Value.Day }) .Select(x => new { Date = x.Key, Count = x.Count() });