这段代码有一个问题:在GROUP BY子句中的datetime_day_Ds是使用了别名,但是在SELECT子句中是无法使用别名的。\n正确的代码应该是这样的:\n\nSELECT toStartOfDay(toDateTime(Ds)) AS datetime_day_Ds,\n PlatformType AS PlatformType,\n max(MergedUrlCount,MergedViewCount) AS index_avgdevicetime_0\nFROM log_iMonkey_Wechat_overview\nWHERE Debug = 0 AND PlatformType != 0 AND\n Ds >= toDateTime(#day_wechat_views_time.start#)\n AND Ds <= toDateTime(#day_wechat_views_time.end#) \n \nGROUP BY toStartOfDay(toDateTime(Ds)),\n PlatformType\nORDER BY datetime_day_Ds DESC,\n PlatformType DESC\nLIMIT 5000;

SQL GROUP BY 子句中使用别名的问题

原文地址: https://www.cveoy.top/t/topic/pxwY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录