关键字组附近的语法不正确 [英] Incorrect syntax near Keyword Group

查看:101
本文介绍了关键字组附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在尝试实施你的解决方案sugesstion一个stroed程序,但它一直给我错误

关键字组附近的语法不正确。我做错了什么?







Hi Everyone
I'm trying to implement your solution sugesstion a stroed procedure but it keep giving me the Error
"Incorrect syntax near Keyword Group". What am i doing wrong?



 SET @Dynamictbl = N'SELECT [Products], [Price], [Finance]

 FROM (
 SELECT [Products], [Price], [Finance] FROM ' + @Table_Name + ' WHERE [Area] = ''PB''' +
' EXCEPT
 SELECT [Products], [Price], [Finance]
FROM ' + @Table_Name2 + ' WHERE [Area] = ''PB''' +
 ')' +
 ' GROUP BY [Products], [Price], [Finance]
 ORDER BY [Products] DESC '

推荐答案

更改此:

Change this:
FROM ' + @Table_Name2 + ' WHERE [Area] = ''PB''' +
 ')' +
 ' GROUP





to:



to:

FROM ' + @Table_Name2 + ' WHERE [Area] = ''PB''' +
 ') AS T ' +
 ' GROUP





您忘记添加别名



You forgot to add alias


您好,

是的,您需要为选定的查询提供名称



试试这个希望这对你有用。



Hi,
Yes you need to give name for the top selected Query

Try this hope this will work for you.

SET @Dynamictbl = N'SELECT [Products], [Price], [Finance]
 
 FROM (
 SELECT [Products], [Price], [Finance] FROM ' + @Table_Name + ' WHERE [Area] = ''PB''' +
' EXCEPT
 SELECT [Products], [Price], [Finance]
FROM ' + @Table_Name2 + ' WHERE [Area] = ''PB''' +
 ') z' +
 ' GROUP BY [Products], [Price], [Finance]
 ORDER BY [Products] DESC '





这里我在分组前添加了z



here i have added " z" before group by


这篇关于关键字组附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆