id RegName PostionSN PersonSN
1 山东齐鲁制药 223 2
2 山东齐鲁制药 224 2
3 北京城建公司 225 2
4 科技公司 225 2
我想获得结果是
id RegName PostionSN PersonSN
1 山东齐鲁制药 223 2
3 北京城建公司 225 2
4 科技公司 225 2
select distinct RegName,PostionSN,PersonSN from table1
如果查询的是多列 distinct 用和不用一样
只能用group by
用group by RegName
select * from table1 where id in (select min(id) from table1 group by RegName) and PersonSN=2
您可能感兴趣的文章: 使用distinct在mysql中查询多条不重复记录值的解决办法 sqlserver中distinct的用法(不重复的记录) 使用GROUP BY的时候如何统计记录条数 COUNT(*) DISTINCT oracle sql 去重复记录不用distinct如何实现 为何Linq的Distinct实在是不给力 解析mysql中:单表distinct、多表group by查询去除重复记录 MongoDB教程之聚合(count、distinct和group) mongodb中使用distinct去重的简单方法 SQL中distinct的用法(四种示例分析) oracle中distinct的用法详解 SQL select distinct的使用方法 针对distinct疑问引发的一系列思考
查看更多关于distinct多列问题结合groupby的解决方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did33786