我有这个SQL:
SELECT (Min(Time_In) & " to " & Max(Time_Out)) AS [Week Of], Round((Sum(DATEDIFF("n", Time_In, Time_Out))/Count(DATEDIFF("n", Time_In, Time_Out))),2) AS [Avg Min of Jog] FROM SomeTable WHERE len(Time_In) > 0 AND len(Time_Out) > 0 AND #01/01/2012# <= Time_In AND #12/31/2012# >= Time_In GROUP BY DatePart('ww',Time_In);
挑选出每周慢跑的平均时间。我也想有一个算很多次,每周慢跑如何,我正在尝试通过计算做jog_id在那里SomeTable可以有5个条目的一个jog_id。
jog_id
SomeTable
我试过了:
SELECT (Min(Time_In) & " to " & Max(Time_Out)) AS [Week Of], Round((Sum(DATEDIFF("n", Time_In, Time_Out))/Count(DATEDIFF("n", Time_In, Time_Out))),2) AS [Avg Min of Jog], Count(distinct jog_id) AS [Num Jogs] FROM SomeTable WHERE len(Time_In) > 0 AND len(Time_Out) > 0 AND #01/01/2012# <= Time_In AND #12/31/2012# >= Time_In GROUP BY DatePart('ww',Time_In);
但这给了我 Syntax error (missing operator) in query expression 'Count(distinct jog_id)'.
Syntax error (missing operator) in query expression 'Count(distinct jog_id)'.
我想念什么?
如果不使用子查询,则无法在Access中执行此操作。 前任:
SELECT Count(*) FROM (SELECT DISTINCT Name FROM table1);
这是有关该主题的详细文章: