在Oracle中,DISTINCT用于從SELECT查詢中返回唯一的結(jié)果集。它可以應(yīng)用于單個(gè)列或多個(gè)列。
語(yǔ)法: SELECT DISTINCT column1, column2, … FROM table_name WHERE condition;
例如,假設(shè)有一個(gè)名為"customers"的表,其中包含"customer_id"和"customer_name"列。如果要返回唯一的customer_name列表,可以使用以下查詢: SELECT DISTINCT customer_name FROM customers;
如果要返回基于多個(gè)列的唯一結(jié)果集,可以使用以下查詢: SELECT DISTINCT customer_id, customer_name FROM customers;
這將返回唯一的customer_id和customer_name的組合。