sqlserver 去掉重复记录

GridView1.DataSource = DBcon.zhuangguangfa.zhuangsqlhelper.GetDatafromzhang("select distinct 学号,姓名,上课班级名称,所属部门 from tab_AllPeopleInfo where 上课班级名称=(select Class from tab_EveryWeek where TeacherName='装潢外聘2' and ThisWeek=15 and Section='9-10节')");

怎么 弄啊。

首先设定表tb_a 唯一关键字段 xh,以及要查询的重复字段 mc 则查询mc重复的sqlserver语句如下
select mc from tb_a where xh not in (select min(xh) xh from tb_a group by mc)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-12-23
distinct已经去除重复的了。你的是不是只在查询显示的时候是重复的呀?
相似回答