我在 SQL Server 2008 中有两个临时表
表 1,results_types
------------
| Result_1 |
| Result_2 |
| Result_3 |
| Result_N |
------------
表 2,all_results
--------------------
| Run_A | Result_1 |
| Run_A | Result_2 |
| Run_B | Result_3 |
| Run_B | Result_3 |
| Run_B | Result_3 |
| Run_B | Result_3 |
| Run_C | Result_2 |
--------------------
如何进行查询以返回摘要,该摘要计算 *results_types* 中的每个条目,而无需遍历 *results_types*。提前致谢
-----------------------------------------------------
| 'Run' | Result_1 | Result_2 | Result_3 | Result_N |
-----------------------------------------------------
| Run_A | 1 | 2 | 0 | 0 |
| Run_B | 0 | 0 | 4 | 0 |
| Run_C | 0 | 2 | 0 | 0 |
-----------------------------------------------------