试图在这里找到所有持有任何一家公司超过 0.5% 股份的股东是我的查询我相信我很接近也附上的图片有架构
![Select Sh.Share_Holder_Id Shareholderid,
Sh.First_Name||' '||Sh.Last_Name Shareholders,
c.name,
sum(T.Share_Amount) ShareAmount
From Trades T
Inner Join
Share_Holders Sh
On
T.Share_Holder_Id =Sh.Share_Holder_Id
Inner Join
Shares S
On
S.Share_Id =T.Share_Id
Inner Join
Companies C
on
C.Company_Id=S.Company_Id
Where exists (
Select
sum(case when shs.amount IS NULL THEN 1 ELSE 0 END)/count (*)*100
From Shares S1
Inner Join Share_Holder_Shares shs
On
Shs.Share_Id=S1.Share_Id
-- where Shs.Amount/t.share_amount * 100 > 0.5
)
Group By Sh.Share_Holder_Id,Sh.First_Name||' '||Sh.Last_Name,C.Name
order by Shareholderid;