sql-server - 计算 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
解决方案
推荐阅读
- windows - Windows App Store 包航班未发送到组
- c - C 程序在调试模式下工作而不在发布模式下工作
- python - 在花括号周围的字符串中添加单引号 - Python
- node.js - 将第二个模式添加到数据库时,一旦编译就无法覆盖“用户”模型。
- javascript - 输入开头没有空格不适用于 addEventListener
- r - R 将绘图保存在 png 中,但不保存在 pdf 中
- mysql - Aggregate function in mariaDB
- mysql - MySQL中的INNER JOIN返回同一行的多个条目
- python - 如何为此 seq2seq 实现创建词汇表?
- electron - Electron 下载文件 - Windows Defender 弹出窗口