常用sql

select * from t_executor;

insert into t_executor (executor_ip) values ('1.1.1.1');


update t_executor set executor_ip = '192.168.3.10' where id=20;


delete from t_executor where id=20;

select 
id, count(id) 
from 
t_r2_result 
where 
to_time 
BETWEEN 
'2023-08-29 10:00:00' and '2023-08-29 20:00:00' 
group by id;


select id, count(id), from_time
from t_r1_result 
where
from_time BETWEEN '2023-08-29 10:00:00' and '2023-08-29 20:00:00'
GROUP BY id ORDER BY from_time ;


select * from t_r2_result as a  
join
(select 
r2.auto_id, r2.id, r2.slot_num, r2.r2_name, r2.result, r2.from_time, r2.to_time,
sum(case when result='pass' then 1 else 0 end) as 成功,
sum(case when result='fail' then 1 else 0 end) as 失败
from t_r2_result r2 where r1_id = '56e19399eac447cd98d29cba3d48e4be' group by r2_name) as b on a.auto_id = b.auto_id 
where a.r1_id = '56e19399eac447cd98d29cba3d48e4be'  group by a.r2_name;


select max(auto_id) from t_r2_result where r1_id = '56e19399eac447cd98d29cba3d48e4be' group by r2_name;


select *
from t_r3_result 
where r2_id='2d50ca4e3c124c7c8b4b4e27c9389501';

#--r2汇总页---------------
SELECT t1.r1_id,  t1.auto_id, t2.max_auto_id, t1.id, t1.slot_num, t1.r2_name, t1.result, t1.from_time, t1.to_time,
t2.成功, t2.失败, (case when t2.失败>0 then 'failf' else 'passp' end) as 状态
FROM t_r2_result t1
INNER JOIN (
    SELECT max(auto_id) AS max_auto_id,
        sum(case when result='pass' then 1 else 0 end) as 成功,
        sum(case when result='fail' then 1 else 0 end) as 失败
    FROM t_r2_result
        where r1_id = '56e19399eac447cd98d29cba3d48e4be'
    GROUP BY r2_name
) t2 ON t1.auto_id = t2.max_auto_id;

#----------------
select id, r2_name from t_r2_result as a  where a.r1_id = '56e19399eac447cd98d29cba3d48e4be' and r2_name = 'camera_fps';

#--查看r3子项详情--------------------
select * from t_r3_result t1 where r2_id in (select id from t_r2_result as a  where a.r1_id = '56e19399eac447cd98d29cba3d48e4be' and r2_name = 'camera_fps')
and t1.r3_name='Camera FPS test';

#--勾选查看r2测试详情r3汇总--速度快--------------------
select 
t1.*,    t4.成功, t4.失败
from t_r3_result t1 
inner JOIN
    (select max(t2.auto_id) as max_auto_id,
            sum(case when t2.result='pass' then 1 else 0 end) as 成功,
            sum(case when t2.result='fail' then 1 else 0 end) as 失败
    from t_r3_result t2
    where t2.r2_id in 
        (select id from t_r2_result a 
        where a.r1_id = '56e19399eac447cd98d29cba3d48e4be' and r2_name = 'camera_fps')
    GROUP BY t2.r3_name) t4 
on t4.max_auto_id = t1.auto_id;


#--勾选查看r2测试详情r3汇总--速度较慢------------------
select t1.* from t_r3_result t1 
where t1.auto_id in
    (select max(t2.auto_id) as max_auto_id from t_r3_result t2
    where t2.r2_id in 
        (select id from t_r2_result a 
        where a.r1_id = '56e19399eac447cd98d29cba3d48e4be' and r2_name = 'camera_fps')
    GROUP BY t2.r3_name);


#----------------------
select * from t_r1_result ORDER BY from_time desc limit 10;


#----------------------
select * from t_r2_result where r1_id = '81cf5c7b2c8d45b3882cb5787427735c' GROUP BY r2_name;


#----------------------
set @var='81cf5c7b2c8d45b3882cb5787427735c';
SELECT t1.r1_id,  t1.auto_id, t2.max_auto_id, t1.id, t1.slot_num, t1.r2_name, t1.result, t1.from_time, t1.to_time,
t2.成功, t2.失败, (case when t2.失败>0 then 'failf' else 'passp' end) as 状态
FROM t_r2_result t1
INNER JOIN (
    SELECT max(auto_id) AS max_auto_id,
        sum(case when result='pass' then 1 else 0 end) as 成功,
        sum(case when result='fail' then 1 else 0 end) as 失败
    FROM t_r2_result
        where r1_id = @var
    GROUP BY r2_name
) t2 ON t1.auto_id = t2.max_auto_id;


#----------------------
select * from t_r3_result t3 inner join
    (select max(t1.auto_id) as max_id from t_r3_result t1 where t1.r2_id in
        (select t2.id 
        from t_r2_result t2 
        where r1_id = '81cf5c7b2c8d45b3882cb5787427735c' and r2_name = 'uss_check') 
    group by t1.r3_name) t4
on t4.max_id = t3.auto_id;


select * from t_r3_result t1 where r2_id  in 
    (select id from t_r2_result t2
    where t2.r1_id = '81cf5c7b2c8d45b3882cb5787427735c' and t2.r2_name = 'uss_check')
and t1.r3_name = 'get uss_id';


select * from t_r3_result t1 inner join
    (select id from t_r2_result t2
    where t2.r1_id = '81cf5c7b2c8d45b3882cb5787427735c' and t2.r2_name = 'uss_check') t3
on t1.r2_id = t3.id
where t1.r3_name = 'get uss_id';


select * from t_test_case;


select * from t_r1_result limit 100;


EXPLAIN select id from t_r1_result;


delete from t_executor where id=5 or id=6;


show status;

show status like 'slow_queries';


show variables like 'long_query_time';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值