select
distinct to_char(a.日期字段,'yyyy-mm-dd')
from
表 a
where
1=1
and to_char(a.日期字段,'yyyy')='2003'
and to_char(a.日期字段,'MM')='06'
order by
1
distinct to_char(a.日期字段,'yyyy-mm-dd')
from
表 a
where
1=1
and to_char(a.日期字段,'yyyy')='2003'
and to_char(a.日期字段,'MM')='06'
order by
1
count(distinct to_char(a.日期字段,'yyyy-mm-dd'))
from
表 a ;
加一个count即可
group by to_char(ur_date_col,'YYYYMM')
count(distinct to_char(a.日期字段,'yyyy-mm-dd'))
from
表 a ;
group by to_char(ur_date_col,'YYYYMM')
-------------------
1980-12-17 00:00:00
1981-02-20 00:00:00
1981-02-22 00:00:00
1981-04-02 00:00:00
1981-09-28 00:00:00
1981-05-01 00:00:00
1981-06-09 00:00:00
1987-04-19 00:00:00
1981-11-17 00:00:00
1981-09-08 00:00:00
1987-05-23 00:00:00HIREDATE
-------------------
1981-12-03 00:00:00
1981-12-03 00:00:00
1982-01-23 00:00:00已选择14行。SQL> select trunc(hiredate,'mm'),count(trunc(hiredate)) from emp group by trunc(hiredate,'mm');TRUNC(HIREDATE,'MM' COUNT(TRUNC(HIREDATE))
------------------- ----------------------
1980-12-01 00:00:00 1
1981-02-01 00:00:00 2
1981-04-01 00:00:00 1
1981-05-01 00:00:00 1
1981-06-01 00:00:00 1
1981-09-01 00:00:00 2
1981-11-01 00:00:00 1
1981-12-01 00:00:00 2
1982-01-01 00:00:00 1
1987-04-01 00:00:00 1
1987-05-01 00:00:00 1已选择11行。SQL>