查询1988年出生的学生(tt_student)表,显示学号,姓名,出生年月(注意:此题不能用出生日期字段来计算,用年龄来计算) 怎么写 个位大神们!!

解决方案 »

  1.   

    select student_id, name, born_date
      from tt_student
    where to_char(sysdate, 'yyyy') - to_char(born_date, 'yyyy') = 30
      

  2.   

    select student_id, name, born_date
      from tt_student
    where to_date(sysdate, 'yyyy') - to_date(born_date, 'yyyy') = 30 
      

  3.   

    楼上的,日期不能用to_date
      

  4.   

    select student_id, name, born_date
      from tt_student
    where to_char(sysdate, 'yyyy') - to_char(born_date, 'yyyy') = 30
      

  5.   

    select student_id, name, born_date
    from tt_student
    where to_char(sysdate, 'yyyy') - to_char(born_date, 'yyyy') = 30
      

  6.   

    select student_id, name, born_date
      from tt_student
    where to_char(sysdate, 'yyyy') - to_char(born_date, 'yyyy') = 30
      

  7.   

    select student_id, name, born_date
      from tt_student
     where to_char(sysdate, 'yyyy') - to_char(born_date, 'yyyy') =
           (to_char(sysdate, 'yyyy') - 1998)
      

  8.   

    如果在不知道是30岁 的情况下呢

    select student_id, name, born_date
      from tt_student
     where to_char(sysdate, 'yyyy') - to_char(born_date, 'yyyy') =
           (to_char(sysdate, 'yyyy') - 1988)