SELECT Prj_DBName FROM kiyunstm_bq.t_projects 查询出库名,然后根据库名查询SELECT s.Prj_Uid,v.Version_No,CONCAT( s.Soft_Name , '-',vtl.VTL_TechStrategy ) AS Test_level_name,a.TestItem,a.testType,a.use_cases,b.instance_data, CONCAT( a.use_cases , '/',b.instance_data) AS cases_instances FROM t_softlist AS s INNER JOIN t_testversion AS v ON v.TreeUid = s.TreeUid INNER JOIN t_versiontotestlevel AS vtl ON vtl.Version_Uid = v.Version_Uid LEFT JOIN view_soft_testreqcanbuildusecase AS qcan ON qcan.VTL_Uid = vtl.VTL_Uid LEFT JOIN ( SELECT qcan.TestItem,qcan.testType,COUNT(us.TreeUid) AS use_cases FROM view_soft_testreqcanbuildusecase AS qcan INNER JOIN t_usecase AS us ON us.TreeUid = qcan.ReqTreeUid GROUP BY qcan.TestType )AS a ON a.TestItem = qcan.TestItem LEFT JOIN ( SELECT qcan.TestItem,qcan.testType,COUNT(uci.UC_Uid) AS instance_data FROM view_soft_testreqcanbuildusecase AS qcan INNER JOIN t_usecase AS us ON us.TreeUid = qcan.ReqTreeUid INNER JOIN t_ucinstances AS uci ON uci.UC_Uid = us.UC_Uid GROUP BY qcan.TestType )AS b ON b.testType = a.testType GROUP BY Test_level_name,a.TestType
时间: 2024-04-13 20:30:39 浏览: 118
要根据前一个查询结果中的库名查询相关信息,你可以将第一个查询作为子查询,并在第二个查询中使用这个子查询的结果。以下是修改后的查询语句示例:
```
SELECT s.Prj_Uid, v.Version_No, CONCAT(s.Soft_Name, '-', vtl.VTL_TechStrategy) AS Test_level_name, a.TestItem, a.testType, a.use_cases, b.instance_data,
CONCAT(a.use_cases, '/', b.instance_data) AS cases_instances
FROM t_softlist AS s
INNER JOIN t_testversion AS v ON v.TreeUid = s.TreeUid
INNER JOIN t_versiontotestlevel AS vtl ON vtl.Version_Uid = v.Version_Uid
LEFT JOIN view_soft_testreqcanbuildusecase AS qcan ON qcan.VTL_Uid = vtl.VTL_Uid
LEFT JOIN (
SELECT qcan.TestItem, qcan.testType, COUNT(us.TreeUid) AS use_cases FROM view_soft_testreqcanbuildusecase AS qcan
INNER JOIN t_usecase AS us ON us.TreeUid = qcan.ReqTreeUid
GROUP BY qcan.TestType
) AS a ON a.TestItem = qcan.TestItem
LEFT JOIN (
SELECT qcan.TestItem, qcan.testType, COUNT(uci.UC_Uid) AS instance_data FROM view_soft_testreqcanbuildusecase AS qcan
INNER JOIN t_usecase AS us ON us.TreeUid = qcan.ReqTreeUid
INNER JOIN t_ucinstances AS uci ON uci.UC_Uid = us.UC_Uid
GROUP BY qcan.TestType
) AS b ON b.testType = a.testType
WHERE s.Prj_Uid IN (
SELECT Prj_Uid
FROM kiyunstm_bq.t_projects
)
GROUP BY s.Prj_Uid, Test_level_name, a.TestType;
```
在这个查询语句中,我们添加了一个`WHERE`子句,使用`IN`关键字将第一个查询结果中的库名作为条件进行筛选。请确保将`t_projects`和其他表名替换为实际的表名。
阅读全文