SELECT toStartOfDaytoDateTimeDs AS datetime_day_Ds PlatformType AS PlatformType maxMergedUrlCountMergedViewCount AS index_avgdevicetime_0FROM log_iMonkey_Wechat_overviewWHERE Debug = 0 AND Platform
这段代码有一个问题:在GROUP BY子句中的datetime_day_Ds是使用了别名,但是在SELECT子句中是无法使用别名的。 正确的代码应该是这样的:
SELECT toStartOfDay(toDateTime(Ds)) AS datetime_day_Ds, PlatformType AS PlatformType, max(MergedUrlCount,MergedViewCount) AS index_avgdevicetime_0 FROM log_iMonkey_Wechat_overview WHERE Debug = 0 AND PlatformType != 0 AND Ds >= toDateTime(#day_wechat_views_time.start#) AND Ds <= toDateTime(#day_wechat_views_time.end#)
GROUP BY toStartOfDay(toDateTime(Ds)), PlatformType ORDER BY datetime_day_Ds DESC, PlatformType DESC LIMIT 5000
原文地址: http://www.cveoy.top/t/topic/hOsf 著作权归作者所有。请勿转载和采集!