无法在列上进行GROUP BY - 替代解决方案?

时间:2014-10-15 11:40:32

标签: mysql sql innodb

SELECT journey.code, ADDTIME(journey.departure, SEC_TO_TIME(SUM(link2.elapsed))) AS stopDeparture, service.line, getDestination(pattern.section), service.code
FROM journey
JOIN journey_day ON journey_day.journey = journey.code
JOIN pattern ON pattern.code = journey.pattern
JOIN service ON service.code = journey.service
JOIN link ON link.section = pattern.section AND link.stop = "1000DMLF7767"
JOIN link link2 ON link2.section = pattern.section AND link2.id <= link.id
WHERE journey_day.day = 3 AND journey.code NOT IN   (SELECT journey
                                                     FROM journey_non_operation
                                                     WHERE "2014-10-15" BETWEEN date_start AND date_end)
GROUP BY stopDeparture, service.line
ORDER BY departure

尝试运行上面的查询时,我在输出日志中看到以下内容:

错误代码:1056。无法分组'stopDeparture'

我不确定为什么这是不可能的,我想要做的就是将stopDeparture值和行值相同的行分组。

我是否有另一种方法可以避免此错误,但可以达到上述所需的效果?

0 个答案:

没有答案