I have a query, that returns all entries, with unique datetime with ticks:
select t.date, count(*) as Count
from table t
group by t.date having count(*) = 1
I need a query that will return entries with unique datetime without ticks. To get datetime without ticks I’m using:
select CONVERT(VARCHAR(19), t.date, 120), count(*) as Count
from table t
So I’m expecting to use query:
select CONVERT(VARCHAR(19), t.date, 120), count(*) as Count
from table t
group by CONVERT(VARCHAR(19), t.date, 120) having count(*) = 1
But it throws an error:
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.
Do you have any idea what query should I use?
This works fine: