我正在擺弄創建子查詢以適應它們。如果某個人的ID出現在聯結表X次數中,我試圖獲得ID號和相關費用。我試過子查詢中的聚合
select id, charges from myTable
where id in
(
select id from jxnTable
having (count(jxn.id> 10))
group by jxn.id
這給我的錯誤jxn.id is invalid in the select list because it is not contained in either an aggregate function of a group by clause.
哎呀,對不起,我編輯你的答案,而不是我的:頁面刷新,我點擊了錯誤的鏈接。 – dasblinkenlight
我知道這可以通過加入完成,但我試圖讓自己熟悉子查詢:) – wootscootinboogie
@dasblinkenlight我在編輯過程中彈出編輯通知 - 我的習慣是複製所有我自己的編輯所以我可以粘貼回編輯:) –