在SQL中,DISTINCT關鍵字用于返回唯一不重復的結果集。在查詢中的應用包括:
SELECT DISTINCT column_name
FROM table_name;
SELECT DISTINCT column1, column2
FROM table_name;
SELECT COUNT(DISTINCT column_name)
FROM table_name;
SELECT DISTINCT column_name
FROM table_name
WHERE condition;
總的來說,DISTINCT關鍵字在查詢中的應用是用來返回唯一的值,幫助我們過濾重復數據,得到準確的結果集。