SQL 来自子查询的最大值,消息 102,')' 附近的语法不正确

SQL Max from Subquery, Msg 102, Incorrect syntax near ')'

我试图只获取每天总和的最大结果。我正在尝试这个 Select 来自(子查询)的 Max(Anzahl)

子查询本身有效,但是当我将它放入括号中时,出现以下错误消息:

Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ')'.

整个查询见下文。

非常感谢任何提示! 干杯 卢卡斯

select Max(Anzahl) from
(
select CONVERT(VARCHAR(10), log1.timestamp, 104) as Date, log1.ID, count(*) Anzahl
from log1
inner join base on log1.ID = base.ID
where abc like '%test%' and log1.xyz = 3
GROUP BY CONVERT(VARCHAR(10), log1.timestamp, 104), log1.ID
)

在SQL中,每个派生的table都需要一个别名,这样它就可以被唯一识别,所以

select Max(Anzahl) from
(
select CONVERT(VARCHAR(10), log1.timestamp, 104) as Date, log1.ID, count(*) Anzahl
from log1
inner join base on log1.ID = base.ID
where abc like '%test%' and log1.xyz = 3
GROUP BY CONVERT(VARCHAR(10), log1.timestamp, 104), log1.ID
) as AliasName