查询今天数据:
SELECT COUNT(1) FROM T_CALL_RECORDS WHERE TO_CHAR(T_RKSJ,'YYYY-MM-DD')=TO_CHAR(SYSDATE,'YYYY-MM-DD')
查询昨天数据:
SELECT COUNT(1) FROM T_CALL_RECORDS WHERE TO_CHAR(T_RKSJ,'YYYY-MM-DD')=TO_CHAR(SYSDATE-1,'YYYY-MM-DD')
查询本周数据:
SELECT COUNT(1) FROM T_CALL_RECORDS WHERE T_RKSJ >= TRUNC(NEXT_DAY(SYSDATE-8,1)+1) AND T_RKSJ < TRUNC(NEXT_DAY(SYSDATE-8,1)+7)+1
查询上周数据:
SELECT COUNT(1) FROM T_CALL_RECORDS WHERE T_RKSJ >= TRUNC(NEXT_DAY(SYSDATE-8,1)-6) AND T_RKSJ < TRUNC(NEXT_DAY(SYSDATE-8,1)+1)
查询本月数据:
SELECT COUNT(1) FROM T_CALL_RECORDS WHERE TO_CHAR(T_RKSJ,'YYYY-MM')=TO_CHAR(SYSDATE,'YYYY-MM')
查询上月数据:
SELECT COUNT(1) FROM T_CALL_RECORDS WHERE TO_CHAR(T_RKSJ,'YYYY-MM')=TO_CHAR(ADD_MONTHS(SYSDATE,-1),'YYYY-MM')
查询表名及字段信息数据:
SELECT A.TABLE_NAME 表名,A.COLUMN_NAME 字段名,A.COMMENTS 字段注释,B.DATA_TYPE 字段类型,B.DATA_LENGTH 字段长度,B.NULLABLE 是否为空,C.INDEX_NAME 索引名称
FROM USER_COL_COMMENTS A
LEFT JOIN USER_TAB_COLUMNS B ON A.COLUMN_NAME = B.COLUMN_NAME AND A.TABLE_NAME=B.TABLE_NAME
LEFT JOIN USER_IND_COLUMNS C ON A.COLUMN_NAME = C.COLUMN_NAME AND A.TABLE_NAME=C.TABLE_NAME
WHERE A.TABLE_NAME = '表名'
ORDER BY B.COLUMN_ID
备注:NEXT_DAY(SYSDATE,1)函数为当前系统时间的下个星期日时间,数字1代表星期日;
注意:本文归作者所有,未经作者允许,不得转载