飞道的博客

metersphere的功能接口用例数统计

414人阅读  评论(0)

统计功能用例数

人员维度统计

  1. 统计每个人员2023年的有效功能用例数
    要求:输出字段 创建人、功能用例数,只展示有创建功能用例的人员
select create_user 创建人,count(1) 功能用例数
from test_case tc 
where tc.status !='Trash' 
and tc.delete_time  is null 
and FROM_UNIXTIME(create_time/1000,'%Y')='2023'
group by create_user 
  1. 统计每个人员2023年的有效功能用例数
    要求:输出字段 创建人、功能用例数,展示平台所有用户,并按功能用例数降序
select u1.id 创建人,u2.case_num 功能用例数
from user u1
left join (
	select create_user,count(1) case_num
	from test_case tc 
	where tc.status !='Trash' 
	and tc.delete_time  is null 
	and FROM_UNIXTIME(create_time/1000,'%Y')='2023'
	group by create_user 
) u2
on u1.id=u2.create_user
order by u2.case_num desc 

项目维度统计

  1. 统计每个项目下2023年创建的有效功能用例数
    要求:输出字段 项目id,项目名称,功能用例数;只展示有功能用例的项目
select p.id 项目id,p.name 项目名称,count(1) 功能用例数
from project p 
join test_case tc 
on p.id=tc.project_id 
and  tc.status !='Trash' 
and tc.delete_time  is null 
and FROM_UNIXTIME(tc.create_time/1000,'%Y')='2023'
group by p.id,p.name
  1. 统计每个项目下2023年创建的有效功能用例数
    要求:输出字段 项目id,项目名称,功能用例数;展示平台所有项目,并按功能用例数降序
select p.id 项目id,p.name 项目名称,count(tc.id) 功能用例数
from project p 
left join test_case tc 
on p.id=tc.project_id 
and  tc.status !='Trash' 
and tc.delete_time  is null 
and FROM_UNIXTIME(tc.create_time/1000,'%Y')='2023'
group by p.id,p.name
order by count(tc.id) desc 

统计接口用例数

人员维度统计

  1. 统计每个人员2023年的有效接口用例数
    要求:输出字段 创建人、接口用例数,只展示有创建接口用例的人员
select create_user_id 创建人,count(1) 接口用例数
from api_test_case tc 
where tc.status !='Trash' 
and tc.delete_time  is null 
and FROM_UNIXTIME(create_time/1000,'%Y')='2023'
group by create_user_id 
  1. 统计每个人员2023年的有效接口用例数
    要求:输出字段 创建人、接口用例数,展示平台所有用户,并按接口用例数降序
select u1.id 创建人,u2.api_case_num 接口用例数
from user u1
left join (
	select create_user_id,count(1) api_case_num
	from api_test_case tc 
	where tc.status !='Trash' 
	and tc.delete_time  is null 
	and FROM_UNIXTIME(create_time/1000,'%Y')='2023'
	group by create_user_id 
) u2
on u1.id=u2.create_user_id
order by u2.api_case_num desc 
select u1.id 创建人,count(u2.id) 接口用例数
from user u1
left join api_test_case u2
on u1.id=u2.create_user_id 
and u2.status !='Trash' 
and u2.delete_time  is null 
and FROM_UNIXTIME(u2.create_time/1000,'%Y')='2023'
group by u1.id
order by count(u2.id) desc

项目维度统计

  1. 统计每个项目下2023年创建的有效接口用例数
    要求:输出字段 项目id,项目名称,接口用例数;只展示有接口用例的项目
select p.id 项目id,p.name 项目名称,count(1) 接口用例数
from project p 
join api_test_case tc 
on p.id=tc.project_id 
and  tc.status !='Trash' 
and tc.delete_time  is null 
and FROM_UNIXTIME(tc.create_time/1000,'%Y')='2023'
group by p.id,p.name
  1. 统计每个项目下2023年创建的有效接口用例数
    要求:输出字段 项目id,项目名称,接口用例数;展示平台所有项目,并按接口用例数降序
select p.id 项目id,p.name 项目名称,count(tc.id) 接口用例数
from project p 
left join api_test_case tc 
on p.id=tc.project_id 
and  tc.status !='Trash' 
and tc.delete_time  is null 
and FROM_UNIXTIME(tc.create_time/1000,'%Y')='2023'
group by p.id,p.name
order by count(tc.id) desc 

思考:

count(1)count(*)count(field)count(distinct field) 有什么区别?

转载:https://blog.csdn.net/weixin_38093452/article/details/128906428
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场