共計 1543 個字符,預計需要花費 4 分鐘才能閱讀完成。
這篇文章主要講解了“oracle 怎么實現按天,周,月,季度,年查詢排序”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學習“oracle 怎么實現按天,周,月,季度,年查詢排序”吧!
oracle 按天,周,月,季度,年查詢排序
天 –to_char(t.start_time, YYYY-MM-DD)
周 –to_char(t.start_time, YYYY),to_char(t.start_time, IW)
月度 –to_char(t.start_time, YYYY-MM)
季度 –to_char(t.start_time, YYYY),to_char(t.start_time, Q)
年度 –to_char(t.start_time, YYYY)
按天查詢
select to_char(t.start_time, YYYY-MM-DD) day ,count(*) from test t
where to_char(t.start_time, YYYY)= 2019 – 條件限制
group by to_char(t.start_time, YYYY-MM-DD) – 分組
order by to_char(t.start_time, YYYY-MM-DD) – 排序
按周查詢
select to_char(t.start_time, YYYY) year ,to_char(t.start_time, IW),count(*) from test t
where to_char(t.start_time, YYYY)= 2019 – 條件限制
group by to_char(t.start_time, YYYY) year ,to_char(t.start_time, IW)– 分組
order by to_char(t.start_time, YYYY) year,to_char(t.start_time, IW) – 排序
按月度查詢
select to_char(t.start_time, YYYY-MM) ,count(*) from test t
where to_char(t.start_time, YYYY)= 2019 – 條件限制
group by to_char(t.start_time, YYYY-MM) – 分組
order byto_char(t.start_time, YYYY-MM) – 排序
按季度查詢
select to_char(t.start_time, YYYY) year ,to_char(t.start_time, Q),count(*) from test t
where to_char(t.start_time, YYYY)= 2019 – 條件限制
group by to_char(t.start_time, YYYY) ,to_char(t.start_time, Q)– 分組
order byto_char(t.start_time, YYYY) ,to_char(t.start_time, Q)– 排序
按年度查詢
select to_char(t.start_time, YYYY) year ,count(*) from test t
where to_char(t.start_time, YYYY)= 2019 – 條件限制
group by to_char(t.start_time, YYYY) – 分組
order by to_char(t.start_time, YYYY) – 排序
感謝各位的閱讀,以上就是“oracle 怎么實現按天,周,月,季度,年查詢排序”的內容了,經過本文的學習后,相信大家對 oracle 怎么實現按天,周,月,季度,年查詢排序這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關知識點的文章,歡迎關注!