SQL Select 不同于 Table

SQL Select Distinct from Table

我有以下语句,效果很好:

 select 'the file type is:', FileType 
 from table1

我想在这个语句中使用 DISTINCT,例如:

select 'the file type is:', distinct FileType 
from table1

但我收到错误:

Incorrect syntax near the keyword 'distinct'.

我正在使用 SQL Server 2008。

DISTINCT 应该紧跟在 SELECT 之后,像这样:

SELECT DISTINCT 'the file type is:', FileType FROM table1

您必须在要返回的任何列之前放置 "DISTINCT"。

DISTINCT 关键字适用于整个结果,而不仅仅是一列。试试这个:

select DISTINCT 'the file type is:', FileType from  table1