码迷,mamicode.com
首页 > 数据库 > 详细

ORACLE 语句

时间:2018-09-21 13:27:58      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:like   table   语句   注释   批量   upd   oracl   tab   经验   

最近接触数据上传,从前辈汲取经验,以及自己写的一些sql语句,方便以后统计数据,以及进行一些修改操作。

1--查询各部门数据量

--注意:结束日期设置为当前日期的下一天

select e.name, zz.sumCount

  from (select z.dept_id, sum(count) as sumCount

          from (select t.dept_id,

                       t.contents,

                       sql_excute(‘select count(*) from ‘ || t.table_name ||

                                  ‘ where xypt_entry_date > to_date(‘ ||

                                  chr(39) || ‘2018-09-01‘ || chr(39) || ‘,‘ ||

                                  chr(39) || ‘yyyy-MM-dd‘ || chr(39) ||

                                  ‘) and xypt_entry_date <to_date(‘ ||

                                  chr(39) || ‘2018-09-28‘ || chr(39) || ‘,‘ ||

                                  chr(39) || ‘yyyy-MM-dd‘ || chr(39) || ‘) AND DATA_STATE=1‘) as count           

                  from ustcdms.dms_contents t

                  where 1=1

                 -- and t.bus_type = ‘sgsxx‘ –查询双公示数据则取消注释,只查询双公示

                  ) z

         group by z.dept_id) zz,

       ustcdms.dms_tree e

 where zz.dept_id = e.id

 order by e.id

 

 

2--查询各目录数据量 查询某个时间段到现在的数据

 select e.name,

        t.contents,

        sql_excute(‘select count(*) from ‘ || t.table_name ||

                   ‘ where xypt_entry_date > to_date(‘ || chr(39) ||

                   ‘2017-07-01‘ || chr(39) || ‘,‘ || chr(39) ||

                   ‘yyyy-MM-dd‘ || chr(39) || ‘)‘) as count

   from ustcdms.dms_contents t, ustcdms.dms_tree e

  where t.dept_id = e.id

  order by t.dept_id;

 

3.查询各目录数据量 查询某个部门

 select e.name

 

,

        t.contents,

        sql_excute(‘select count(*) from ‘ || t.table_name ||

                   ‘ where xypt_entry_date >= to_date(‘ || chr(39) ||

                   ‘2018-01-01‘ || chr(39) || ‘,‘ || chr(39) ||

                   ‘yyyy-MM-dd‘ || chr(39) || ‘) and xypt_entry_date <to_date(‘ ||

                                  chr(39) || ‘2018-04-19‘ || chr(39) || ‘,‘ ||

                                  chr(39) || ‘yyyy-MM-dd‘ || chr(39) || ‘)‘) as count

   from ustcdms.dms_contents t, ustcdms.dms_tree e

  where t.dept_id = e.id  and e.name

 

 like ‘市公安局‘

  order by t.dept_id

 

 4--查询各目录数据量  查询某个时间段内

 select e.name,

        t.contents,

       sql_excute(‘select count(*) from ‘ || t.table_name ||

                                  ‘ where xypt_entry_date > to_date(‘ ||

                                  chr(39) || ‘2017-07-01‘ || chr(39) || ‘,‘ ||

                                  chr(39) || ‘yyyy-MM-dd‘ || chr(39) ||

                                  ‘) and xypt_entry_date <to_date(‘ ||

                                  chr(39) || ‘2017-07-28‘ || chr(39) || ‘,‘ ||

                                  chr(39) || ‘yyyy-MM-dd‘ || chr(39) || ‘)‘) as count

   from ustcdms.dms_contents t, ustcdms.dms_tree e

  where t.dept_id = e.id

  order by t.dept_id;

 

5.数据上传失败后,当批量修改某个时间段中的时间信息,统一修改

 

UPDATE T_01090059 t

 SET t.xypt_entry_date = to_date(‘2018-09-21 10:21:00‘,

                                   ‘yyyy-mm-dd hh24:mi:ss‘)

 WHERE t.name = ‘黄林‘

   and t.xypt_entry_date >=

       to_date(‘2018-09-21 10:05:29‘, ‘yyyy-mm-dd hh24:mi:ss‘);   (删除‘t.name=‘黄林’and’ 则是修改当前时间内所有的数据)

 

ORACLE 语句

标签:like   table   语句   注释   批量   upd   oracl   tab   经验   

原文地址:https://www.cnblogs.com/jianshuai520/p/9685909.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!