0
このクエリはなぜ機能しませんか?私はエラー "単一グループのグループ機能ではない"を取得します。Oracle。 sum()にサブクエリを掛けます。
select sum(stock.stkprice) * (select nation.exchrate from nation where nation.natcode = 'UK') from stock;
サブクエリが複数の値を返す可能性がありますか?それはプライマリキー、natcodeを使用しているので、単一の為替レートしか返してはいけません。以下はその表です。
create table nation
(natcode char(3) not null,
natname char(20),
exchrate number(9,5),
constraint pk_nation primary key (natcode));
create table stock
(stkcode char(3) not null,
stkfirm char(20),
stkprice number(6,2),
stkqty number(8),
stkdiv number(5,2),
stkpe number(5),
natcode char(3),
constraint pk_stock primary key (stkcode),
constraint fk_hasnation foreign key (natcode) references nation(natcode));