我可以在 mysql 或类似的东西的 BETWEEN
语句中使用 as
吗?
SELECT * FROM 状态
WHERE 日期 BETWEEN CONVERT_TZ('2013-11-01 00:00:00','GMT','UTC')
AND CONVERT_TZ('2013-11-07 23:59:59','GMT','UTC') 作为第一周
AND 日期 BETWEEN CONVERT_TZ('2013-11-08 00:00:00','GMT','UTC')
AND CONVERT_TZ('2013-11-15 23:59:59','GMT','UTC') 作为第二周
AND 日期 BETWEEN CONVERT_TZ('2013-11-16 00:00:00','GMT','UTC')
AND CONVERT_TZ('2013-11-22 23:59:59','GMT','UTC') 作为第二周
按日期排序
我遇到语法错误。如何使用 BETWEEN
来使用别名?每周有没有其他命名方式,这将作为我的标识符。
您正在为表达式设置别名,而不是选定的列
你应该像这样制作 ir:
SELECT t.* FROM
(SELECT s.*, CONVERT(...) as field1, CONVERT(...) as field2 from status) t
...then do what you want with fieldsXX...
我是一名优秀的程序员,十分优秀!