除了要有一个查询显示来自NodeGuid列匹配的两个表中的列之外,我还要向每行添加一列,该行包含此查询中包含当前行的table1.NodeGuid的总行数。
SELECT table1.NodeGuid
, table2.MarkerGuid mg
, --Need this column which contains a count of the total rows in this query that contain the current row's table1.NodeGuid
FROM table1
, table2
WHERE table2.NodeGuid = table1.NodeGuid
Run Code Online (Sandbox Code Playgroud)
谢谢。
您可以使用窗口功能。。。以及正确,明确,标准的 JOIN语法:
SELECT table1.NodeGuid, table2.MarkerGuid mg,
COUNT(*) OVER (PARTITION BY table1.NodeGuid) as cnt
FROM table1 JOIN
table2
ON table2.NodeGuid = table1.NodeGuid
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
59 次 |
| 最近记录: |