有表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()
相关文章:
- 几个常用的sql语句 2022-12-23
- 50个常用sql语句 2022-12-23
- SQL之50个常用的SQL语句 2022-02-02
- 两个神奇的SQL语句 2022-12-23
- 经典SQL语句大全、50个常用的sql语句 2022-12-23
- oracle 常用sql语句 oracle 常用sql语句 2022-12-23
- 50个常用的sql语句 - linzheng 2021-12-04