<!--query by day --SELECTDate_format (Created_date,'%y-%m-%d') asTimesum( Money) Money fromO_finance_detailwhereorg_id= + GROUP by Time<!--Monthly Query --SELECTDate_format (Created_date,'%y-%m') asTimesum( Money) Money fromO_finance_detailwhereorg_id= + GROUP by Time<!--Search by year --SELECTDate_format (Created_date,'%Y') asTimesum( Money) Money fromO_finance_detailwhereorg_id= + GROUP by Time<!--Weekly Query --SELECTDate_format (Created_date,'%y-%u') asTimesum( Money) Money fromO_finance_detailwhereorg_id= + GROUP byTime
Date_format (Date,format) formats the DATE value according to the format string. The following modifiers can be used in the format string:%M-month name (January ... December)%W-week name (Sunday ... Saturday)%D The date of the month with English prefixes (1st, 2nd, 3rd, etc.). )%Y years, numbers,4bit%Y years, numbers,2bit%a abbreviated weekday name (Sun ... Sat)%Number of days in the D-month, number (xx...... to) %Number of days in the E-month, number (0...... to) %M-month, number ( on...... A) %C Month, number (1...... A) %b Abbreviated month name (Jan ...Dec) %J Number of Days in a year (001......366) %H Hours (xx...... at) %K Hours (0...... at) %H Hours ( on...... A) %I-Hour ( on...... A) %L Hours (1...... A) %I minute, number (xx...... -) %R time, AHours (hh:mm:ss[AP]M)%T time, -hours (HH:MM:SS)%s seconds (xx...... -) %s seconds (xx...... -) %P AM or PM%W one days in the week (0=Sunday ...6=Saturday)%U Week (0...... the), here Sunday is the first day of the week%U Week (0...... the), here Monday is the first day of the week%%A text "%”。
RowSpan span of table by TIME group
$cjrili _group = Db::query ("Select Time,count (*) row_num from Think_cjrili where 1 group by Time ") ;
MySQL group statistics by week, month, day