没说清楚
是两个字段在同一年?
left(字段1,4)=left(字段2,4)oracle
to_number(to_date(date1,"yyyy"))=to_number(to_date(date2,"yyyy"))
================================================================ok?

解决方案 »

  1.   

    if you are using SQL Server, try (actually it is meaningless)datepart(month,convert(datetime,yourDateTextColumn)) >=1
    and datepart(month,convert(datetime,yourDateTextColumn)) <=12you probably want
    datepart(year,convert(datetime,yourDateTextColumn)) = 2002for example:datepart(month,convert(datetime,'2002-9-1'))
    datepart(month,convert(datetime,'2002-10-10'))
      

  2.   

    where datepart("m",日期)>="1" and datepart("m",日期)<="12"
      

  3.   

    对不起,没有把意思说清楚。其实是这样的:
    我有一个表,内容示例如下编号  类别  日期       金额
    --------------
    a     蔬菜  2002-9-1  5.00
    a     蔬菜  2002-8-25 15.00
    a     蔬菜  2002-8-2  35.00
    a     牛肉  2002-8-2  25.00
    a     牛肉  2002-8-6  25.00
    ----------------------我想统计每个月的销售总金额,按月及类别分类。要求得到以下结果:a   蔬菜  9月份  5.00
    a   蔬菜  8月份  50.00
    a   牛肉  8月份  50.00这样子的。
      

  4.   

    select 类别,substr(日期,6,2),sum(金额) group by substr(日期,6,2),类别
      

  5.   

    to LanYuCSDN(小宇) :
    JETSQL支持substr这个函数吗?我只在vfp中看到了有这个函数,另外,按照你写的,日期必须为“2002-06-25”这种长日期格式,而对于access中的短日期格式(“2002-6-25”)是没有用的呀,(结果会是“6-”)
      

  6.   

    select 类别,DatePart("M",日期),sum(金额) group by DatePart("M",日期),类别