SQL表

2015-02-04 59 views
0

SELECT DISTINCT我有下面的語句,其工作只是正常:SQL表

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的

+2

鮮明的屬於前面。它適用於整個結果集,而不是單個列。 – ryanyuyu

回答

2

DISTINCT應該SELECT後來的權利,就像這樣:

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

0

你有任何要返回的列之前,把「不同」。

1

DISTINCT關鍵字適用於整個結果,而不僅僅是一列。試試這個:

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