对Oracle中的特定列使用不重复 [英] Using distinct for specific column in oracle
问题描述
可以在oracle中进行以下查询
Followinq query is possible in oracle
select DISTINCT(COLA), COLB
from TABLEA
在此查询中,
- 此查询将为COLA和COLB的组合返回不同的值吗?
- 如果此查询仅为COLA返回单独的值,那么所选COLA的COLB值应该是什么?
- 或者如果我们有多个具有相同COLA值的记录,此查询会引发错误吗?
推荐答案
在您的示例中,查询针对COLA和COLB的组合返回了不同的值。
检查语法:
In your example the query returns distinct values for the combination of COLA and COLB.
Examine the syntax:
注意,则 DISTINCT / UNIQUE / ALL 只能放在SELECT之后和选择列表中第一个表达式的前面。
文档说:
https://docs.oracle.com/cd /B19306_01/server.102/b14200/statements_10002.htm
Note, that DISTINCT/UNIQUE/ALL can be only placed after SELECT and before of the first expression in the select list.
The documentation says that:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm
DISTINCT | UNIQUE
如果您希望数据库仅返回所选的每组重复行的一个
副本,则指定DISTINCT或UNIQUE。这两个关键字是
的同义词。重复的行是选择列表中每个
表达式具有匹配值的行。
Specify DISTINCT or UNIQUE if you want the database to return only one copy of each set of duplicate rows selected. These two keywords are synonymous. Duplicate rows are those with matching values for each expression in the select list.
ALL
如果希望数据库返回所有选定的行,请指定ALL,
包括所有重复项。默认值为ALL。
Specify ALL if you want the database to return all rows selected, including all copies of duplicates. The default is ALL.
上面的意思是,DISTINCT / UNIQUE始终应用于整个选择列表,而不是单个列< br>
The above means, that DISTINCT/UNIQUE is always applied to the whole select list, not to individual columns
这篇关于对Oracle中的特定列使用不重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!