Select
*
from [myTable]
WHERE [myTable].ID IN
(
Select
Min([myTable].ID),
[myTable].Username
FROM [myTable]
group by [myTable].Username);
删除重复的记录给我的错误:我不知道它为什么给这个错误。在主键
You have written a subquery that can return more than one field without using EXISTS reserved word in the main query's FROM clause. Revise the Select statement of the subquery to request only one field
我用户名重复的记录,所以我想用的ID号MIN作为第一个记录用户名是为了消除他们正确。有人可以帮助或告诉我在哪里看?
+------+-------+-------+---------+--------------+
| Data | id | Fname | Lname | Status |
+------+-------+-------+---------+--------------+
| 1 | 12345 | Kunal | Kumar | completed |
| 2 | 12345 | Kunal | Kumar | Not Started |
| 3 | 12346 | Rahul | Malviya | Completed |
| 4 | 12346 | Rahul | Malviya | Not Started |
+------+-------+-------+---------+--------------+
向我们展示db模式,样本数据,当前和预期输出。 \t请阅读[**如何提问**](http://stackoverflow.com/help/how-to-ask) \t \t这里是一个伟大的地方[** START **] (http://spaghettidba.com/2015/04/24/how-to-post-at-sql-question-on-a-public-forum/)来了解如何提高您的问题质量并获得更好的答案。 \t [**如何创建一个最小,完整和可验证的示例**](http://stackoverflow.com/help/mcve) –
仍然需要预期的输出 –
谢谢,它的工作。我猜在内部查询我们不应该使用用户名列,删除后,查询工作正常。谢谢胡安 –