我有3個選擇查詢:結合了COUNT(*),組選擇查詢由
查詢1:
select MMBID, MMBStartDate, MMBEnddate from MMBT1, MMBT2
where MMBT1.Profile_ID = MMBT2.Profile_ID
問題2:
(SELECT Profile_ID, COUNT(vp.Viewed_ProfileId) AS viewed FROM dbo.Viewed_Profiles vp
GROUP BY vp.Profile_Id),
問題3:
SELECT Profile_ID, COUNT(fp.Favorite_ProfileId) AS favorites FROM dbo.Favorite_Profiles fp
GROUP BY fp.Profile_Id
現在我如何將所有這些3選擇sts和g等從查詢1的follwing列作爲輸出
- :
MMBID, MMBStartDate, MMBEnddate
- 從QUERY2:
COUNT(vp.Viewed_ProfileId) AS viewed
- 從QUERY3:
COUNT(fp.Favorite_ProfileId) AS favorites
感謝烏拉圭回合的幫助 孫
(SELECT Profile_ID, COUNT(vp.Viewed_ProfileId) AS viewed FROM dbo.Viewed_Profiles vp
GROUP BY vp.Profile_Id),
(SELECT Profile_ID, COUNT(fp.Favorite_ProfileId) AS favorites FROM dbo.Favorite_Profiles fp
GROUP BY fp.Profile_Id
)
現貨..謝謝你們的幫助。現在我學習了一個新的子句「With」 – Sun