两个常用的SQL语句拾零

有表Test结构如下
ID                   name
1                      aa
2                      bb
3                      cc
4                      dd
5                      aa
6                      ac
7                      cc
8                      df
第一个语句删除重复的数据。但想在重复的数据中只保留一条记录
SQL语句为
delete from test where id not in( select min([id ]) from test group by [name])
第二个语句要求随机获得5条数据,SQL语句为
select top 5 * from test order by newid()

原文地址:https://www.cnblogs.com/jillzhang/p/443238.html