How to sort queries by day, week, month, quarter and year by oracle
This article mainly explains the "oracle how to achieve by day, week, month, quarter, annual query sorting", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "oracle how to achieve daily, weekly, monthly, quarterly, annual query sorting" bar!
Oracle sorts queries by day, week, month, quarter, and year
Tian-to_char (t.startfutimejinjia YYYYMMMMI DD')
Week-to_char (t. Startkeeper timeline), to_char (t. Startkeeper timememe e. I W')
Month-to_char (t. Startkeeper timejour YYYYMM')
Quarter-to_char (t.startroomtimejinyyyy`), to_char (t.startfutimetimestamping Q')
Year-to_char (t.startkeeper timedepartment YYYY')
Query by day
Select to_char (t.startkeeper time.YYYYMurMMMurDD') day, count (*) from test t
Where to_char (t.startkeeper time.YYYY') = '2019'-conditional restrictions
Group by to_char (t.startkeeper time.YYYYMurMMMurDD')-grouping
Order by to_char (t.startkeeper time.YYYYMurMMMurDD')-- sort
Query by week
Select to_char (t.startkeeper time.yyyyyyyyyy`) year, to_char (t.startroomtimetimecompanyieIW'), count (*) from test t
Where to_char (t.startkeeper time.YYYY') = '2019'-conditional restrictions
Group by to_char (t. Startkeeper timejournal / YYYY') year, to_char (t. Startkeeper timecomp / I W')-grouping
Order by to_char (t. Startkeeper time.yyyy') year,to_char (t. Startkeeper timecomp. IW')-- sort
Query by month
Select to_char (t.startkeeper time.YYYYMurMM'), count (*) from test t
Where to_char (t.startkeeper time.YYYY') = '2019'-conditional restrictions
Group by to_char (t.startkeeper time.YYYYmurMM')-grouping
Order byto_char (t.startkeeper time.yyyymurmm`)-sort
Query by quarter
Select to_char (t.startkeeper time.yyyyyyyyy`) year, to_char (t.startshitimetimecompagem quotation Q'), count (*) from test t
Where to_char (t.startkeeper time.YYYY') = '2019'-conditional restrictions
Group by to_char (t. Startkeeper timejournal YYYY'), to_char (t. Startkeeper timecomp Q')-- grouping
Order byto_char (t. Startkeeper timejournal yyyy'), to_char (t. Startkeeper timepenny Q')-- sort
Query by year
Select to_char (t.startkeeper time) year, count (*) from test t
Where to_char (t.startkeeper time.YYYY') = '2019'-conditional restrictions
Group by to_char (t.startkeeper time.YYYY')-grouping
Order by to_char (t.startkeeper time.yyyy')-sort
Thank you for your reading, the above is the "oracle how to achieve by day, week, month, quarter, annual query sorting" of the content, after the study of this article, I believe that how to achieve oracle by day, week, month, quarter, annual query sorting this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!