Вопрос про Mssql

laki

create table #t
(
Amount int,
DT datetime,
PaperID int,
OptionType int,
FuturePrice numeric(18, 6
Strike numeric(18, 6
TimeToEnd numeric(18, 6
RiskFreeRate numeric(18, 6
Premium numeric(18, 6)
)
create table #a
(
TotalAmount int,
PaperID int
)
insert into #a (TotalAmount, PaperID)
select sum(#t.Amount #t.PaperID from #t where #t.paperid is not null group by #t.PaperID)
Выдает ошибку:
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
Как это альтернативно решить?

sinet

попробуй...
insert into #a (TotalAmount, PaperID) select * from (
select sum(#t.Amount #t.PaperID from #t where #t.paperid is not null group by #t.PaperID
)

laki

внутренний селект выступает как subquery. та жа самая ошибка

6yrop

на SQL Server 2005 твой пример ошибки не выдает

laki

да блин таблицу забыли дропнуть
все вопрос закрыт
Оставить комментарий
Имя или ник:
Комментарий: