1024programmer Oracle Oracle summarizes according to the time statistics statement

Oracle summarizes according to the time statistics statement

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

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/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索