首页 > 解决方案 > 计算 3 个表中的多次出现并创建/插入到第 4 个表中

问题描述

使用 SQL Server,计算 3 个表中的多个重复项目并使用总和创建第 4 个表的最佳方法是什么?参见示例:

样本数据:

table 1     table 2     table 3 
name        name        name     value
John Doe    John Doe    John Doe    v1
Mary Smith  Mary Smith  John Doe    v2
John Doe    John Doe    Mary Smith  v1                          
Mary Smith              John Doe    v3                          
John Doe                Mary Smith  v1                          
                        Mary Smith  v2                          
                        John Doe    v2                          

预期成绩:

Result table of counts                  
name       t1 t2 t3v1 t3v2 t3v3
John Doe    3  2    1    2   1
Mary Smith  2  1    2    1   0

标签: sql-serverreporting-services

解决方案


推荐阅读