SELECT date_uploaded,
(SELECT CAST(tablename.date_uploaded AS date) AS Expr1) AS newdate
FROM tablename
我的问题是,如何GROUP BY
给出新的虚拟列(Expr1
)?
答案 0 :(得分:1)
在大多数数据库中,您需要在group by
:
SELECT date_uploaded, CAST(tablename.date_uploaded AS date) AS newdate
FROM tablename
GROUP BY CAST(tablename.date_uploaded AS date);
对于简单的表达式,完全没有嵌套的SELECT
。我不知道人们在哪里学会做这些事情,但我在过去看过类似的例子。
答案 1 :(得分:0)
最简单的方法:
SELECT * FROM
(
SELECT date_uploaded,
(SELECT CAST(tablename.date_uploaded AS date) AS Expr1) AS newdate
FROM tablename
)AS TB
GROUP BY TB.newdate