我有一张桌子,我正在运行以下两个查询:
首先查询:
select distinct q1."InstituteId" from (
select siid as "InstituteId" from ptable
union all
select riid as "InstituteId" from ptable
) q1
第二次查询:
select q2."InstituteId" from (
select siid as "InstituteId" from ptable
union all
select riid as "InstituteId" from ptable
) q2
目标是从第一个查询中获得所有研究所(即)
InstituteId
1
1
2
3
3
4
...
并与第二个查询中的不同ID合并并执行组,因此输出如下:
InstituteId Count
1 2
2 1
3 2
...
我不知道接下来该怎么办。请提前告知并提前致谢!
答案 0 :(得分:0)
这就是你要找的东西吗?:
<docZip>
Text which is not allowed
<childElement>
</chilElement>
</docip>
答案 1 :(得分:0)
试过这个..看起来我太过于复杂了:
select q2."InstituteId", count(q2."InstituteId") as "COUNT" from (
select siid as "InstituteId" from ptable
union all
select riid as "InstituteId" from ptable
) q2
group by q2."InstituteId"