select distinct 
       a.os_username os_user,
       a.userhost,
       a.username db_user,
       to_char(a.timestamp,'yyyy-mm') Year_Month,
       a.action_name action_name       
from   dba_audit_trail a
where  a.timestamp >= to_date(to_char(sysdate,'yyyymm')-1||'16','yyyymmdd') 
and    a.timestamp < to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd')
and          a.action in (100)
order by a.action_nameselect distinct 
       a.os_username os_user,
       a.userhost,
       a.username db_user,
       to_char(a.timestamp,'yyyy-mm') Year_Month,
       a.action_name action_name       
from   dba_audit_trail a
where  a.timestamp >= to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd') 
and    a.timestamp < to_date(to_char(sysdate,'yyyymm')||'16','yyyymmdd')
and          a.action in (100)
order by a.action_name求教这几句话是什么意思???

解决方案 »

  1.   

    这不就是普通的sql吗。
    有啥特殊,难懂的地方?
      

  2.   

    where  a.timestamp >= to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd') 
    and    a.timestamp < to_date(to_char(sysdate,'yyyymm')||'16','yyyymmdd')
    这两句不明白是什么意思oracle以前没用过
      

  3.   

    timestamp >= 本月一号
    timestamp <  本月十六号
      

  4.   

    where  a.timestamp >= to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd') 
    and    a.timestamp < to_date(to_char(sysdate,'yyyymm')||'16','yyyymmdd')
    这两句不明白是什么意思oracle以前没用过
    这个就是个简单的日期比对啊。 timestamp  也是 oracle 的一个日期类型,精度高点而已。
      

  5.   

    如果 不知道意思  可以单独查询出来 to_date(to_char(sysdate,'yyyymm')||'01','yyyymmdd') 1、to_char(sysdate,'yyyymm') 先查询当前年月 201309
    2、||'01' ||为合并符号 结果会显示20130901 就是当前月份的第一天
    3、to_date 然后将第一天转换成日期格式 
    4、表中数据 根据这个时间段来过滤出 符合当月1-16号的数据