1

所以我一直在遇到这个问题,也许有人可以很好地解释它如何或为什么不起作用。我正在尝试仅按一列 CSHFutureTAs.Time 进行分组,并且我尝试集成简单的行

GROUP BY CSHFutureTAs.Time

但是,这给了我一个错误“您尝试执行的查询不包含指定表达式'TA'作为聚合函数的一部分”,有人可以帮助我吗?

完整的 SQL(没有 GROUP CLAUSE):

    SELECT CSHFutureTAs.TA
   , CSHFutureTAs.TIME AS CSHGeneralTAs_TIME
   , CSHFutureTAs.[CUT OFF         TIME]
   , CSHFutureTAs.SUNDAY AS CSHGeneralTAs_SUNDAY
   , CSHFutureTAs.MONDAY AS CSHGeneralTAs_MONDAY
   , CSHFutureTAs.TUESDAY AS CSHGeneralTAs_TUESDAY
   , CSHFutureTAs.WEDNESDAY AS CSHGeneralTAs_WEDNESDAY
   , CSHFutureTAs.THURSDAY AS CSHGeneralTAs_THURSDAY
   , CSHFutureTAs.FRIDAY AS CSHGeneralTAs_FRIDAY
   , CSHFutureTAs.SATURDAY AS CSHGeneralTAs_SATURDAY
   , FUT_Totals.TIME AS GeneralTotals_Time
   , FUT_Totals.SUNDAY AS GeneralTotals_SUNDAY
   , FUT_Totals.MONDAY AS GeneralTotals_MONDAY
   , FUT_Totals.TUESDAY AS GeneralTotals_TUESDAY
   , FUT_Totals.WEDNESDAY AS GeneralTotals_WEDNESDAY
   , FUT_Totals.THURSDAY AS GeneralTotals_THURSDAY
   , FUT_Totals.FRIDAY AS GeneralTotals_FRIDAY
   , FUT_Totals.SATURDAY AS GeneralTotals_SATURDAY
   , CSHFutureTAs.[EXCEPTION DAYS]
   , CSHFutureTAs.[EXCEPTION VALUE]
   , IIf([FUT_Totals] ! [Time] = "09:00 - 21:00"
      OR [FUT_Totals] ! [Time] = "10:00 - 22:00", 9, 1) AS SortKey
FROM
(
   CSHFutureTAs
   INNER JOIN FUT_Totals ON (CSHFutureTAs.[HG ID] = FUT_Totals.HG_ID)
      AND (CSHFutureTAs.TIME = FUT_Totals.TIME)
)
INNER JOIN Current_INFO ON (CSHFutureTAs.[HG ID] = Current_INFO.[HG ID])
   AND (CSHFutureTAs.[HEADER ID] = Current_INFO.[HEADER ID])
   AND (FUT_Totals.HG_ID = Current_INFO.[HG ID])
ORDER BY IIf([FUT_Totals] ! [Time] = "09:00 - 21:00"
      OR [FUT_Totals] ! [Time] = "10:00 - 22:00", 9, 1);
4

1 回答 1

1

GROUP BY CSHFutureTAs.Time你的条款到底在哪里?

您需要按一列分组,并且不属于该组的任何其他列都必须具有聚合函数,例如 SUM 或 AVG。

另外,我认为您的 FROM 上不需要该 parentesys。你为什么加那个?

于 2012-10-22T12:46:49.990 回答