外部引用我有一個查詢爲:如何消除子查詢
SELECT DISTINCT A2P.p_year [Year], A2P.aid [CoAuthor]
FROM sub_aminer_author2paper A2P
WHERE pid IN (
SELECT A2P.pid
FROM sub_aminer_author2paper A2P
JOIN sub_aminer_paper P ON A2P.pid = P.pid
WHERE DATALENGTH(P.p_abstract) > 0 AND
A2P.aid IN (
SELECT aid
FROM Authors
) AND A2P.p_year BETWEEN 2005 AND 2014
)
AND A2P.aid NOT IN (
SELECT aid
FROM Authors
)
ORDER BY Year, CoAuthor
該查詢給我輸出:
Year CoAuthor
2005 796
2005 947
2005 1032
2005 1740
2005 1960
2005 4045
2005 4472
...
...
而我想有輸出:
Author Year CoAuthor Venue
677 2005 796 234565
677 2005 947 127634
677 2005 1032 235487
1359 2005 1740 341265
1359 2005 1960 23658
1359 2005 4045 3412
1359 2005 4472 235473
...
...
我手動添加的列是aid
的部分查詢,即SELECT aid FROM Authors
。如何選擇?而我也使用A2P.aid NOT IN (SELECT aid FROM Authors)
,因爲我不想在CoAuthor
列中顯示Author
列。
請幫忙。
@Thorsten KETTNER額外添加的列即'Venue'在另一個名爲表'sub_aminer_paper' – maliks