Ref: 77638826
-Table structure
-
CREATE TABLE' Zk_score ' (' ID ')varchar(255) not NULLCOMMENT'Rating Table', ' name 'varchar(255)DEFAULT NULLCOMMENT'Name of Institution', ' TOTALSCR 'varchar(255)DEFAULT NULLCOMMENT'Comprehensive score', ' Unfiorm 'varchar(255)DEFAULT NULLCOMMENT'Consistency', ' complete 'varchar(255)DEFAULT NULLCOMMENT'completeness', ' standard 'varchar(255)DEFAULT NULLCOMMENT'Normative', ' timely 'varchar(255)DEFAULT NULLCOMMENT'timeliness of', ' rank 'varchar(255)DEFAULT NULLCOMMENT'ranking', ' Createtime 'varchar(255)DEFAULT NULLCOMMENT'Update Time', ' status 'varchar(255)DEFAULT NULLCOMMENT'Status', PRIMARY KEY(' id ') USING BTREE) ENGINE=InnoDBDEFAULTCHARSET=UTF8 Row_format=DYNAMIC;
-Table Data
-
-sql
-
SelectA.click_date as datetime, Ifnull (B.TOTALSCR,0) asTotalscr, Ifnull (B.standard,0) asStandard , Ifnull (B.complete,0) asComplete , Ifnull (B.unfiorm,0) asUnfiorm, Ifnull (b.timely,0) asTimely from ( SELECTCurdate () asclick_dateUnion All SELECTDate_sub (Curdate (), Interval1 Day) asclick_dateUnion All SELECTDate_sub (Curdate (), Interval2 Day) asclick_dateUnion All SELECTDate_sub (Curdate (), Interval3 Day) asclick_dateUnion All SELECTDate_sub (Curdate (), Interval4 Day) asclick_dateUnion All SELECTDate_sub (Curdate (), Interval5 Day) asclick_dateUnion All SELECTDate_sub (Curdate (), Interval6 Day) asclick_date) A Left Join ( SelectDate (Createtime) as datetime, AVG(TOTALSCR) TOTALSCR,AVG(Standard),AVGComplete ,AVG(Unfiorm) Unfiorm,AVG(timely) Timely fromZk_scoreGroup byDate (createtime)) b onA.click_date=B.datetime ORDER byA.click_dateASC;
-Query Results
-
-Get nearly 7 days another SQL
-
SELECT @num:= @num + 1, Date_format (Date_sub (curdate ()+1, INTERVAL@num Day),'%y-%m-%d') asDate fromZk_monit, (SELECT @num:= 0) TWHEREdate_sub (curdate ()+1, INTERVAL@num Day)<=Date_format (Curdate ()+1,'%y-%m-%d' ) and @num <7ORDER byDateDESC;
MySQL Query last week (last 7 days) data