首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

求教这句sql什么意思。该怎么解决

2013-09-07 
求教这句sql什么意思。。。select distincta.os_username os_user,a.userhost,a.username db_user,to_char(a.

求教这句sql什么意思。。。



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_name

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')||'01','yyyymmdd') 
and    a.timestamp < to_date(to_char(sysdate,'yyyymm')||'16','yyyymmdd')
and          a.action in (100)
order by a.action_name

求教这几句话是什么意思???
[解决办法]
timestamp >= 本月一号
timestamp <  本月十六号
[解决办法]
引用:
Quote: 引用:

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

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 的一个日期类型,精度高点而已。
[解决办法]
如果 不知道意思  可以单独查询出来

 to_date(to_char(sysdate,'yyyymm')
[解决办法]
'01','yyyymmdd') 

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

 to_date(to_char(sysdate,'yyyymm')
[解决办法]
'01','yyyymmdd') 

1、to_char(sysdate,'yyyymm') 先查询当前年月 201309
2、
[解决办法]
'01' 
[解决办法]
为合并符号 结果会显示20130901 就是当前月份的第一天
3、to_date 然后将第一天转换成日期格式 
4、表中数据 根据这个时间段来过滤出 符合当月1-16号的数据

总结的很好,佩服
[解决办法]
结的很好,佩服

热点排行