泛微常用sql语句

  • 登陆最少统计:
    select top 5 relatedname,COUNT(*) as c from SysMaintenanceLog where operateitem=60 group by relatedname order by c asc
  • 待办事宜数量前十机构统计:
    select top 10 (select SUBSTRING(subcompanyname,3,6) from hrmsubcompany where id=subcompanyid1),count(requestid) as cid from workflow_currentoperator  ,hrmresource where  hrmresource.id =workflow_currentoperator.userid and isremark in (0,1,8,9) and islasttimes=1 group by subcompanyid1 order by cid desc
  • 员工数前十机构分布:
    select top 10 (select subcompanyname from hrmsubcompany where id=subCompanyId1),count(id) As cids  from hrmresource group by subCompanyId1 order by cids desc
  • 项目统计前十机构:
    select top 10 (select SUBSTRING(subcompanyname,3,6) from hrmsubcompany where id=hrmdepartment.subcompanyid1),count(*)  as cid from Prj_ProjectInfo ,hrmdepartment where Prj_ProjectInfo.department=hrmdepartment.id group by hrmdepartment.subcompanyid1 order by cid desc
  • ----oracle:按照月份统计-过生日人员排名前10:
    select * from (select substr(birthday, 6, 2) , count(1) s  from hrmresource where status in (0, 1, 2, 3)   and birthday is not null group by substr(birthday, 6, 2) order by s desc  ) a where rownum<=10;
  • --sqlserver:按照月份统计-过生日人员排名前10:
    select top 10 SUBSTRING(birthday,6,2) , count(1) s  from hrmresource  where status in (0, 1, 2, 3)   and birthday is not null and  birthday !='' group by SUBSTRING(birthday,6,2) order by s desc;
  • --oracle:登录排名前10:
    select *  from (select (select lastname from HrmResource where id = relatedid) as lastname, count(1) s from SysMaintenanceLog where operatetype = 6 and operateitem = 60 group by relatedid  order by s desc) a where rownum <= 10;
  • --sqlserver:登录排名前10:
    select top 10 (select lastname from HrmResource where id =relatedid) as lastname , count(1) s  from SysMaintenanceLog where operatetype = 6   and operateitem = 60 group by relatedid order by s desc;
  • 登陆次数排名:
    select * from (select relatedname,count(*) as 系统登陆次数 from SysMaintenanceLog where operatetype = 6 and operatedate between '2012-07-01' and '2020-12-31' group by relatedid,relatedname order by count(*) desc)where rownum<=10
  • 流程操作次数:
    select * from (select (select lastname from hrmresource where id = userid),count(*) as 流程操作人次数 from workflow_currentoperator where workflowid!=301 group by userid order by count(*) desc)where rownum<=10
  • 发起流程数排名:
    select * from (select  (select lastname from hrmresource where id = creater) as 用户,count(*) as 发起流程次数 from workflow_requestbase where workflowid<>301 group by creater order by count(*) desc)where rownum<=10
  • 近期访问统计:
    select * from (select  operatedate,count(id) as acs from SysMaintenanceLog where operateitem=60 and relatedname<>'系统管理员' group by operatedate order by operatedate desc) where rownum<=10
  • 待办事宜排名:
    select * from (SELECT (select lastname from hrmresource where id =userid), COUNT(requestid) AS Expr1 FROM workflow_currentoperator WHERE workflowtype > 0 and (isremark IN ('0', '1', '5','8','9','7')) AND (islasttimes = 1) AND (usertype = 0)  and exists (select 1 from hrmresource where hrmresource.id=workflow_currentoperator.userid and hrmresource.status in (0,1,2,3) ) AND EXISTS (SELECT 1 FROM workflow_base WHERE id = workflow_currentoperator.workflowid AND (isvalid = '1'))  and exists (select 1 from workflow_requestbase where requestid = workflow_currentoperator.requestid and (deleted=0 or deleted is null)) GROUP BY userid ORDER BY COUNT(requestid) desc) where rownum<=10
  • 登陆最少统计(oracle):
    select relatedname,c from (select relatedname,COUNT(*) as c from SysMaintenanceLog where operateitem=60 group by relatedname order by c asc)where rownum<=5
  • 待办事宜最多的12个人(oracle):
    select lastname,c from (select (select lastname from hrmresource where id=userid) lastname ,count(requestid) as c from workflow_currentoperator where isremark in ('0','8','9') and userid>1 group by userid order by c desc)where rownum<=12
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
泛微OA是一款功能强大的企业办公自动化软件,其数据库使用的是SQL Server。下面是一些常用SQL语句和功能: 1. 数据查询:使用SELECT语句可以从数据库中查询数据。可以通过指定表名、字段名、条件等进行查询,还可以使用通配符、排序和分组等进行高级查询。 2. 数据插入:使用INSERT INTO语句将数据插入到数据库表中。可以指定要插入的表名和字段名,同时提供相应的值。 3. 数据更新:使用UPDATE语句可以更新数据库表中的数据。可以指定要更新的表名、字段名、新值和更新条件。 4. 数据删除:使用DELETE FROM语句可以删除数据库表中的数据。可以指定要删除的表名和删除条件。 5. 数据排序:使用ORDER BY子句可以对查询结果进行排序。可以按照一个或多个字段进行升序或降序排序。 6. 数据聚合:使用GROUP BY子句可以对查询结果进行分组。可以按照一个或多个字段进行分组,并对每个分组进行聚合操作,如计数、求和、平均值等。 7. 数据连接:使用JOIN语句可以通过共同字段将多个表连接起来,获取相关联的数据。 8. 数据筛选:使用WHERE子句可以对查询结果进行筛选。可以使用各种逻辑条件进行数据过滤,如等于、不等于、大于、小于等。 总而言之,泛微OA常用SQL语句主要涉及数据查询、插入、更新、删除,以及排序、分组、连接和筛选等功能。通过合理运用这些SQL语句,可以快速有效地操作和管理数据库中的数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值