标签:
USE SQLSERVER; SELECT * FROM EMP; SELECT DISTINCT MGR FROM EMP; SELECT DISTINCT DEPTNO FROM EMP; select distinct comm from emp; select distinct comm, deptno from emp; --查询不重复的值 --distinct关键字 select * from emp; select distinct deptno from emp; select distinct deptno as "等级" from emp; select distinct sal from emp; select distinct job from emp; --NULL也是一个值,查询唯一时也把NULL算入 select distinct comm from emp; select distinct deptno, comm from emp; select distinct comm, deptno from emp; select distinct job, ename from emp; --错误的写法 select sal, distinct deptno from emp; --distinct使用来修饰select关键字的,不是用来修饰字段的 select distinct sal, distinct deptno from emp; --distinct使用来修饰select关键字的,不是用来修饰字段的 /* 注意: distinct 修饰的是 select 单个字段:select distinct 查询为单个字段中不重复的 多个字段:select distinct F1, F2, F3... 查询为字段组(所有字段)中不重复的 语法: select distinct F1, F2, F3... (单|多字段)from table; 例如: select distinct deptno, comm from emp 来自 tmp表 查询 deptno, comm组合起来不包含重复数据 语意: 来自table中查询的字段不包含重复数据(单|多字段)的组合 */
标签:
原文地址:http://www.cnblogs.com/MrTarget/p/5639255.html