我想从单个表中选择单个列中的所有重复记录。我使用了以下代码。但是我只能获得一个重复记录。代码如下所示
SELECT Datetime COUNT(*)FROM users GROUP BY Datetime HAVING COUNT(*) > 1
但我想要像下表那样的结果
TableName:MyTable
DateTime
04/16/2015
04/16/2015
04/16/2015
04/16/2015
但我的查询如下所示。
DateTime
04/16/2015 count(4)
请帮助我
答案 0 :(得分:0)
Join
回到原始数据;
SELECT u.*
FROM users u JOIN
(SELECT Datetime
FROM users
GROUP BY Datetime
HAVING COUNT(*) > 1
) d
ON u.Datetime = d.Datetime;
答案 1 :(得分:0)
Select Datetime from Users
where Datetime in
(SELECT Datetime FROM users GROUP BY Datetime HAVING COUNT(*) > 1)