oracle 按每天,每月,每日,年查詢資料量

2021-09-26 08:16:58 字數 1470 閱讀 4461

select * from tablename md 

//按天統計

select to_char(md.createtime,'yyyy-mm-dd') as xx, count(md.billmaindataid) as 每天運算元量, sum(md.naturalamount)

from tablename md

where md.currentstate != 22

group by to_char(md.createtime,'yyyy-mm-dd')

order by xx desc

//按自然月統計

select to_char(md.createtime,'yyyy-mm') as xx, count(md.billmaindataid) as 每天運算元量, sum(md.naturalamount)

from tablename md

--where md.currentstate != 22

--and md.createtime between to_date('2014-01','yyyy-mm') and to_date('2014-12','yyyy-mm')

group by to_char(md.createtime,'yyyy-mm')

order by xx desc

//按年統計

select to_char(md.createtime,'yyyy') as xx, count(md.billmaindataid) as 每天運算元量, sum(md.naturalamount)

from tablename md

--where md.currentstate != 22

group by to_char(md.createtime,'yyyy')

order by xx desc

//按季統計

select to_char(md.createtime,'yyyy-q') as xx, count(md.billmaindataid) as 每天運算元量, sum(md.naturalamount)

from tablename md

--where md.currentstate != 22

group by to_char(md.createtime,'yyyy-q')

order by xx desc

//按自然周統計

select to_char(md.createtime,'yyyy-iw') as xx, count(md.billmaindataid) as 每天運算元量, sum(md.naturalamount)

from tablename md

--where md.currentstate != 22

group by to_char(md.createtime,'yyyy-iw')

order by xx desc

Mysql查詢每天 每週 每月 每年的資料

查詢每天的資料 select count 1 as total,date format create time,y m d as time from op endor info group by date format create time,y m d 查詢每週的資料 select count 1...

mysql查詢每天每週每月每年的資料方法

查詢每天的資料 select count 1 as countnumber,date format createtime,y m d as datetime from testtable group by date format createtime,y m d 查詢每週的資料 select cou...

mysql查詢每天每週每月每年的資料方法

查詢每天的資料 select count 1 as countnumber,date format createtime,y m d as datetime from testtable group by date format createtime,y m d 查詢每週的資料 select cou...