发布网友 发布时间:2022-04-10 09:49
共2个回答
懂视网 时间:2022-04-10 14:10
按mySql语法统计按周,月,季,年。income为合计的价格字段,createDate为交易时间。 select sum(income)as revenue,week(createDate) as week,month(createDate) as month, quarter(createDate)as quarter,year(createDate)as year from employee where year(createDate) >= ‘2006‘ group by week(createDate),month(createDate),quarter(createDate),year(createDate) --sqlserver2005语法统计按周,月,季,年。 --按日 --select sum(price),day([date]) from table_name where year([date]) = ‘2006‘ group by day([date]) --按周quarter select sum(price),datename(week,price_time) from ble_name where year(price_time) = ‘2008‘ group by datename(week,price_time) --按月 select sum(price),month(price_time) from ble_name where year(price_time) = ‘2008‘ group by month(price_time) --按季 select sum(price),datename(quarter,price_time) from ble_name where year(price_time) = ‘2008‘ group by datename(quarter,price_time) --按年 select sum(price),year(price_time) from ble_name where year(price_time) >= ‘2008‘ group by year(price_time)
用sql语句按周、按月、按季、按年统计
标签:时间 div mon body where style mysql serve created
热心网友 时间:2022-04-10 11:18
declare