酱紫应该可以了
select * from your_table where to_char(sysdate,'yyyy')-substr(your_column,1,4)=your_number

解决方案 »

  1.   

    sorry,
    应该这样:
    select * from your_table where to_char(sysdate,'yyyy')-substr(your_column,1,4) <=your_age
    或者
    select * from your_table where to_char(sysdate,'yyyy')-substr(your_column,1,4) >=your_age
    或者
    select * from your_table where to_char(sysdate,'yyyy')-substr(your_column,1,4) between your_age1 and your_age2
      

  2.   

    如下可以
    select '3岁以下',count(*) 年龄 from babytable where ceil((sysdate-to_date(birthday,'yyyy-mm-dd'))/365)<=3 
    union
    select '3-5岁',count(*) 年龄 from babytable where ceil((sysdate-to_date(birthday,'yyyy-mm-dd'))/365)>3 
    and  ceil((sysdate-to_date(birthday,'yyyy-mm-dd'))/365)<=5
    union 
    select '5岁以上',count(*) 年龄 from babytable where ceil((sysdate-to_date(birthday,'yyyy-mm-dd'))/365)>3 
    and  ceil((sysdate-to_date(birthday,'yyyy-mm-dd'))/365)>5
      

  3.   

    建表:Create table ss(a varchar2(20), b number);
    插入的数据:
    A                             B
    -------------------- ----------
    2003.10.1                     1
    2000.10,10                    2
    1999.1.1                      3
    1977.1.1                      4
    查询语句:
     select a,
     case
     when  to_char(sysdate,'yyyy')-substr(a,1,4) in ('0','1','2','3') then '3岁以下'
     when  to_char(sysdate,'yyyy')-substr(a,1,4) in ('3','4','5') then '3-5岁'
     else '5岁以上'
     end as 年龄段,
     b
     from ss;
    结果:
    A                    年龄段           B
    -------------------- ------- ----------
    2003.10.1            3岁以下          1
    2000.10,10           3岁以下          2
    1999.1.1             3-5岁            3
    1977.1.1             5岁以上          4
    不知是不是你想要的结果?