国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

oracle兩個(gè)時(shí)間比較 oracle中怎么按每小時(shí)分組。數(shù)據(jù)如下?

oracle中怎么按每小時(shí)分組。數(shù)據(jù)如下?select time,count(time) from (select substr("2014-01-01 20:03:00",1,13) as time

oracle中怎么按每小時(shí)分組。數(shù)據(jù)如下?

select time,count(time) from (select substr("2014-01-01 20:03:00",1,13) as time from table_name) group by time

oracle查詢一段時(shí)間內(nèi)每一天的統(tǒng)計(jì)數(shù)據(jù)sql怎么寫?

這是sql的基本功。各個(gè)數(shù)據(jù)庫SQL寫法一樣,只是那幾個(gè)函數(shù)不一樣而已。

比如表是datatable,,里面只存了一個(gè)月的數(shù)據(jù),時(shí)間字段biztime,數(shù)量字段qty。要求1-10號(hào)每天8-15點(diǎn)時(shí)段qty之和。語句:

select date_part("day",biztime),sum(qty) from datatable where date_part("day",biztime)>=1 and date_part("day",biztime)<=10 and datepart(hour",biztime)>=8 and date_part(hour",biztime)<15 group by date_part("day",biztime) order by date_part("day",biztime)

結(jié)果:

1 XX

2 XX

3 XX

……

當(dāng)然,以上是最簡單的情況。稍復(fù)雜的情況,比如6號(hào)那天沒數(shù)據(jù),但要求列表中要有6號(hào)(數(shù)量為0),這時(shí)就要用到連接,其實(shí)也是非常簡單啦。