当前位置: 代码迷 >> Sql Server >> 请问一个SQL语句,多谢
  详细解决方案

请问一个SQL语句,多谢

热度:130   发布时间:2016-04-27 19:43:11.0
请教一个SQL语句,谢谢.
表table如下
id         name
1           铅笔
2           小刀
3           铅笔
4           尺子

如何捞出只有1笔记录的结果集?
需要的结果如下
id         name
2           小刀
4           尺子
就是说name有重复的记录不要.
谢谢了.

------解决方案--------------------
select t.* from [table] t where not exists(select 1 from [table] where name=t.name and id <> t.id)
------解决方案--------------------
来晚了
  相关解决方案