--according to MySQL grammar statistics by week, month, quarter, year. Income is the total Price field and CreateDate is the trading time. Select sum(income) asRevenue,week (CreateDate) asWeekMonth(CreateDate) as Month, Quarter (CreateDate) asQuarter Year(CreateDate) as Year fromEmployeewhere Year(CreateDate)>= '2006' Group byWeek (createdate),Month(CreateDate), Quarter (CreateDate), Year(createdate)--sqlserver2005 Grammar statistics by week, month, quarter, year. --by day--Select SUM (Price), day ([date]) from table_name where year ([date]) ='2006' Group by Day([Date])--by week quarterSelect sum(Price),Datename(Week,price_time) fromBle_namewhere Year(Price_time)= ' -' Group by Datename(week,price_time)--by MonthSelect sum(Price),Month(Price_time) fromBle_namewhere Year(price_time)= ' -' Group by Month(price_time)--by seasonSelect sum(Price),Datename(Quarter,price_time) fromBle_namewhere Year(Price_time)= ' -' Group by Datename(quarter,price_time)--by yearSelect sum(Price), Year(Price_time) fromBle_namewhere Year(Price_time)>= ' -' Group by Year(Price_time)
Use SQL statements by week, month, quarter, yearly