当我执行我认为创建得很好的查询时,我有一个异常,错误是:Msg 102,Niveau tat 15,that 1,the 6 Syntaxe incorrecte vers‘’)。在此,请求:
SELECT DISTINCT designation FROM
(select top 100 percent designation , code_piececomptable
from cpt_lignepiececomptable WHERE code_piececomptable IN
(SELECT code_piececomptable
FROM cpt_piececomptable WHERE terminer is null or terminer <>1)
ORDER BY code_piececomptable)发布于 2013-07-25 12:37:08
你需要给它一个化名:
SELECT DISTINCT designation FROM
(select top 100 percent designation , code_piececomptable
from cpt_lignepiececomptable WHERE code_piececomptable IN
(SELECT code_piececomptable
FROM cpt_piececomptable WHERE terminer is null or terminer <>1)
ORDER BY code_piececomptable) q请注意,q加到最后。
发布于 2013-07-25 12:36:10
从cpt_lignepiececomptable WHERE code_piececomptable IN (从cpt_piececomptable中选择code_piececomptable,其中终端为null或<>1)按code_piececomptable顺序选择最高的100 %指定
我认为Order给出子查询中的错误。
试着用这个
问候
阿舒托什·阿里亚
发布于 2013-07-25 12:45:07
至于错误,在另一个答案中提到,这是因为如果您要从中选择,您必须别名您的子查询。
但是,您可以在这里完全重写您的查询,以便根本不使用子查询。
SELECT DISTINCT designation
FROM cpt_lignepiececomptable lpc
INNER JOIN cpt_piececomptable cpc ON lpc.code_piececomptable = cpc.code_piececomptable
WHERE cpc.terminer IS NULL OR cpc.terminer <>1
ORDER BY lpc.code_piececomptablehttps://stackoverflow.com/questions/17858143
复制相似问题