Oracle summarizes according to the time statistics statement
the
Oracle statistics statement by day
http://www.2cto.com/database/201208/148040.html
Oracle statistics statement by week
http://www.2cto.com/database/201208/148083.html
Oracle statistics statement by month
http://www.2cto.com/database/201208/148041.html
Oracle statistics statement by quarter
http://www.2cto.com/database/201208/148085.html
Oracle statistics statement by year
http://www.2cto.com/database/201208/148086.html
the
After reading the few articles I posted above, we can easily find a pattern.
the
According to the time statistics are also regular…
the
Did you notice any difference?
the
–Statistics by day
SELECT TO_CHAR(T.MODIFIEDTIME,’YYYY-MM-DD’) TIME,COUNT(*) COUNT
FROM TEST T
–You can add query conditions here WHERE TO_CHAR(T.MODIFIEDTIME,'YYYY') = TO_CHAR(SYSDATE,'YYYY')
GROUP BY TO_CHAR(T.MODIFIEDTIME,'YYYY-MM-DD') –Group by date
ORDER BY TO_CHAR(T.MODIFIEDTIME, & # 39; YYYY-MM-DD & # 39;) ASC NULLS LAST — Sort by date
the
–Statistics by week
SELECT TO_CHAR(T.MODIFIEDTIME,'YYYY') YEAR,TO_CHAR(T.MODIFIEDTIME,'IW') TIME,COUNT(*) COUNT www.2cto.com
FROM TEST T
–You can add query conditions here WHERE TO_CHAR(T.MODIFIEDTIME,'YYYY') = TO_CHAR(SYSDATE,'YYYY')
GROUP BY TO_CHAR(T.MODIFIEDTIME,'IW'),TO_CHAR(T.MODIFIEDTIME,'YYYY') –Group by week number
ORDER BY TO_CHAR(T.MODIFIEDTIME,'YYYY'),TO_CHAR(T.MODIFIEDTIME,'IW') ASC NULLS LAST –sort by week number
the
— Statistics by month
SELECT TO_CHAR(T.MODIFIEDTIME,’YYYY-MM’) TIME,COUNT(*) COUNT
FROM TEST T
–You can add query conditions here WHERE TO_CHAR(T.MODIFIEDTIME,'YYYY') = TO_CHAR(SYSDATE,'YYYY')
GROUP BY TO_CHAR(T.MODIFIEDTIME,'YYYY-MM') –Group by month
ORDER BY TO_CHAR(T.MODIFIEDTIME,’YYYY-MM’) ASC NULLS LAST –sort by month
the
–Statistics by quarter
SELECT TO_CHAR(T.MODIFIEDTIME,'YYYY') YEAR,TO_CHAR(T.MODIFIEDTIME,'Q') TIME,COUNT(*) COUNT
FROM TEST T
–You can add query conditions here WHERE TO_CHAR(T.MODIFIEDTIME,'YYYY') = TO_CHAR(SYSDATE,'YYYY')
GROUP BY TO_CHAR(T.MODIFIEDTIME,'Q'),TO_CHAR(T.MODIFIEDTIME,'YYYY') –group by quarter of each year
ORDER BY TO_CHAR(T.MODIFIEDTIME,'YYYY'),TO_CHAR(T.MODIFIEDTIME,'Q') ASC NULLS LAST –Sort according to the quarter of each year
the
–Statistics by year
SELECT TO_CHAR(T.MODIFIEDTIME,’YYYY’) YEAR,COUNT(*) COUNT
FROM TEST T www.2cto.com
— You can add query conditions here
GROUP BY TO_CHAR(T.MODIFIEDTIME,'YYYY') –Group by year
ORDER BY TO_CHAR(T.MODIFIEDTIME,'YYYY') ASC NULLS LAST –sort by year
the
Seeing this, I believe you already know the rules.
the
Date and character conversion function usage (to_date, to_char)
selectto_char(sysdate, ‘yyyy-mm-dd
the
hh24:mi:ss')asnowTimefromdual;
the
// convert date to string
the
selectto_char(sysdate,'yyyy')asnowYear fromdual;
// Get the year of the time
the
selectto_char(sysdate,’mm’) asnowMonthfromdual;
//Get the month of time www.2cto.com
the
selectto_char(sysdate,’dd’) asnowDay fromdual;
//Get the day of the time
the
selectto_char(sysdate,'hh24')asnowHour fromdual;
// when to get the time
the
selectto_char(sysdate,’mi’) asnowMinutefromdual;
//Get the minutes of the time
the
selectto_char(sysdate,’ss’) asnowSecondfromdual;
// Get the seconds of the time
the
the
Author guoxuepeng123
Oracle summarizes according to the time statistics statement
This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/oracle-summarizes-according-to-the-time-statistics-statement/