1、distinct关键字:把查询结果去除重复记录注意:原表数据不会被修改,只是查询结果去重。
select distinct job from emp;
2、distinct只能出现在所有字段的最前方。
distinct出现在job,deptno两个字段之前,表示两个字段联合起来去重。
select distinct job,deptno from emp;
3、统计一下工作岗位的数量? select count(distinct job) from emp;
本文介绍了SQL中的distinct关键字在查询时如何去除重复记录,强调它不改变原表数据,以及它在查询结构中的位置。并通过示例展示了如何统计工作岗位的独特数量。
1、distinct关键字:把查询结果去除重复记录注意:原表数据不会被修改,只是查询结果去重。
select distinct job from emp;
2、distinct只能出现在所有字段的最前方。
distinct出现在job,deptno两个字段之前,表示两个字段联合起来去重。
select distinct job,deptno from emp;
3、统计一下工作岗位的数量? select count(distinct job) from emp;
3773

被折叠的 条评论
为什么被折叠?