select count(*) from (select distinct(substr(to_char(pdate,'yyyy-mm'),6,2)) from tname)

解决方案 »

  1.   

    select distinct(to_char(pdate,'yyyy-mm')),to_char(pdate,'yyyy-mm')
    from table
    group by to_char(pdate,'yyyy-mm')
      

  2.   

    select count(distinct(to_char(pdate,'MM'))),to_char(pdate,'MM')
    from table
    group by to_char(pdate,'MM')
      

  3.   

    select To_Char(test_date, 'yyyy-mm'), Count(*) from test group by To_Char(test_date, 'yyyy-mm')
      

  4.   

    有一字段, pdate,类型为date,数据如下:
    2002-3-1
    2002-3-5
    2002-4-1
    2002-5-6
    2002-5-12
    现想得到月份的个数,即to_char(pdate,'yyyy-mm')个数,sql应该怎么写select to_char(pdate,'yyyy-mm'),count( to_char('yyyy-mm')) count
    from table_name 
    group by to_char(pdate,'yyyy-mm')
      

  5.   

    select count(To_Char(test_date, 'yyyy-mm')) from test group by To_Char(test_date, 'yyyy-mm')
      

  6.   

    select count(*) mon_num from Table_Name 
    group by 
    to_char(p_date,'yyyy-mm');
    mon_num:既是昵所需要的个数