我数据库中表中有一个日期字段riq,类型为datetime,其值部分如下:
2008-03-05
2008-04-05
2008-05-08
2008-04-08
2008-07-09
2008-04-09
2008-10-10
2008-11-08
2008-12-11
2008-06-05
2009-01-05
2009-03-05
2009-04-08
2009-05-08
2009-06-09
2009-04-09
2009-09-10
2009-08-05
2009-09-05
2009-11-05
.....
如何取得这个列表的“年份-月份”的唯一值,我主要想知道该表中存在多少个月份的数据(不同年份的同一个月是两个月),在VB中如何取得??????

解决方案 »

  1.   

    select year(riq) & month(riq) 
    from  mytable
    group by year(riq),month(riq)
      

  2.   

    select distinct year(riq) as iyear,month(riq) as imonth from tablename
      

  3.   

    谢谢楼上兄弟!麻烦帮我看看这个是什么原因??
    http://topic.csdn.net/u/20090814/10/fee02edd-e9ca-48f5-a49b-8554af135a2b.html
    我尽快结帖!
      

  4.   

    select distinct CONVERT(char(7),riq,120) as rq from yourTable 
      

  5.   

    你的VB下装过什么第三方插件吗?象codeSmart之类的,它会自动备份你的文件,没有的话看看,不是是中病毒了.