我有一个查询,返回所有条目,具有独特的datetime
蜱:SQL服务器:GROUP BY日期时间无蜱
select t.date, count(*) as Count
from table t
group by t.date having count(*) = 1
我需要一个查询将返回独特datetime
条目没有蜱。为了得到datetime
无蜱我使用:
select CONVERT(VARCHAR(19), t.date, 120), count(*) as Count
from table t
所以我希望使用查询:
select CONVERT(VARCHAR(19), t.date, 120), count(*) as Count
from table t
group by CONVERT(VARCHAR(19), t.date, 120) having count(*) = 1
但它抛出一个错误:
Column "table.date" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
你有什么我应该使用什么查询?
当然,'ORDER BY '!他没有在查询中包含该子句,我完全错过了错误消息中的引用。绝对同意,+1 –