转载源:http://www.jb51.net/article/42613.htm SQL按照日.周.月.季度.年统计数据的方法 方式一: --按日 select sum(consume),day([date]) from consume_record where year([date]) = '2006' group by day([date]) --按周quarter select sum(consume),datename(week,[date]) from consume_record…
group by DATE_FORMAT(createtime,'%Y-%m');//按月统计数据 group by DATE_FORMAT(createtime,'%Y-%m-%d');//按天统计数据 +---------------------------------+----------+ | DATE_FORMAT(createtime,'%Y-%m') | count(*) | +---------------------------------+----------+ | | |…
查看最新用户表统计信息 select owner,table_name,last_analyzed from dba_tables where owner not like '%SYS%' order by 1,3; SELECT Table_Name,Num_Rows,Blocks,Empty_Blocks,Avg_Space,Chain_Cnt,Avg_Row_Len,Sample_Size,Last_AnalyzedFROM Dba_Tables WHERE owner = 'SCOTT'…
PROCEDURE SET_TABLE_STATS Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- OWNNAME VARCHAR2 IN TABNAME VARCHAR2 IN PARTNAME VARCHAR2 IN DEFAULT STATTAB VARCHAR2 IN DEFAULT STATID VARCHAR2 IN DE…