要求找出近一個月的數據,日期應該怎樣寫?

解决方案 »

  1.   

    select * from tb where dt>=add_months(to_date(sysdate),-1)
      

  2.   


         EMPNO NAME                     DEPTNO     MGR_ID     SALARY       COMM HIREDATE           BIRTH              S                                                                                     
    ---------- -------------------- ---------- ---------- ---------- ---------- ------------------ ------------------ -                                                                                     
             2 David                       100          1       7000                               20-11月-60         M                                                                                     
             3 Peter                       200          1       8000                               10-10月-61         M                                                                                     
             4 Harry                       300          1       9000                               20-8月 -66         M                                                                                     
             1 Jack                        999                 10000                               01-1月 -50         M                                                                                     
             5 Ann                         100          2       3500                               18-3月 -85         F                                                                                     
             6 Sue                         200          3       5500                               21-2月 -77         F                                                                                     
             7 Mary                        300          4       6000                               03-4月 -70         F                                                                                     
             8 Sam                         100          2       4100                               19-9月 -74         M                                                                                     
             9 Allen                       200          3       3100                               31-3月 -82         M                                                                                     
            10 Scott                       300          4       2700                               21-7月 -84         M                                                                                     
            11 James                       100          2       2900                               25-6月 -80         M                                                                                     
            12 Apple                       200          3       1800                               19-3月 -90         F   表結構是這個樣子的 應該怎樣比較男女的年齡呢?
      

  3.   

    找出年龄最小的男女员工信息
    select n.*
     from
     (
     SELECT m.*,
            row_number() over(PARTITION BY deptno,s ORDER BY birth desc) rn
       FROM employe m) n
       where n.rn = 1
      

  4.   

    1 \ select * from tb where dt>=add_months(to_date(sysdate),-1)2\ select  min(绝对值函数(t1.出生年月-t2.出生年月))from tb t1,tb t2 
    where t1.性别字段= 男 and
      t2.性别字段= 女 and 
      

  5.   


    1、select * from tb where dt>=add_months(to_date(sysdate),-1) 2、 select  min(ABS(t1.出生年月-t2.出生年月))from tb t1,tb t2  
    where t1.性别字段= 男 and 
      t2.性别字段= 女 and  
      

  6.   


    这个只是第一个表的男的年龄于第二个表的女的的年龄差,where (t1.性别字段= 男 and  
      t2.性别字段= 女)or (t2.性别字段= 男 and  
      t1.性别字段= 女)