小编All*_*len的帖子

加入2个sql选择

我有两个非常相似的sql语句

select instrumentuniqueid, count(levelid) as errors
   from dbo.testevent
   join dbo.test 
   on dbo.test.id = dbo.testevent.testid where dbo.test.runid = 20962 and dbo.testevent.levelid = 1
   group by instrumentuniqueid


select instrumentuniqueid, count(levelid) as warnings
   from dbo.testevent 
   join dbo.test
   on dbo.test.id = dbo.testevent.testid where runid = 20962 and levelid = 2
   group by instrumentuniqueid
Run Code Online (Sandbox Code Playgroud)

第一个产生instrumentuniqueid(聚合)列和计数第二个产生具有不同计数的聚合instrumentuniqueid列.

如何将它们连接在一起,以便最终表格如下所示:

Instrumentuniqueid | 错误| 警告

sql select join

1
推荐指数
1
解决办法
43
查看次数

标签 统计

join ×1

select ×1

sql ×1