错误:“DISTINCT”或其附近的语法错误

时间:2014-09-18 12:36:22

标签: postgresql

为什么会出现此错误?我需要选择这两个区别,但我在这里编码错了吗?

ERROR: syntax error at or near "DISTINCT"

SELECT DISTINCT(mfin_score), DISTINCT(empirica_score ) from account_details

5 个答案:

答案 0 :(得分:4)

你可以这样做:

select distinct mfin_score, empirica_score
  from account_details

关键字distinct不是函数。这是一个关键字,表示您只需要distinct个结果集上的元组。

答案 1 :(得分:4)

DISTINCTKEYWORD而非FUNCTION,因此如果您尝试

会更好
SELECT DISTINCT mfin_score, empirica_score from account_details

答案 2 :(得分:2)

只需使用此

SELECT DISTINCT mfin_score,来自account_details的empirica_score

答案 3 :(得分:2)

如果你想要mfin和empirica的独特夫妻:

select distinct mfin_score, empirica_score
  from account_details

如果你想要独特的mfin和独特的经验,你必须做一些不同的事情:

select distinct 'MFIN' As code, mfin_score
 from account_details
union all
select distinct 'EMP' As code, empirica_score
from account_details

您可能需要检查postgresql for Alias的语法,不确定它是否与oracle相同

答案 4 :(得分:2)

DISTINCT关键字的正确语法是

SELECT DISTINCT column_name,column_name FROM table_name;

所以你可以写

SELECT DISTINCT mfin_score, empirica_score from account_details

而不是

SELECT DISTINCT(mfin_score), DISTINCT(empirica_score ) from account_details