SQL2005 报错 在关键字'group' 附近有语法错误select a,b,sum(x) from (select a,b,'1' as x from aaaunion allselect a,b,'-1' as x from bbb)group by a,b改成下面这样还是同样报错:select a,b,sum(x) from (select a,b,'1' as x from aaa
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/28 05:37:11
![SQL2005 报错 在关键字'group' 附近有语法错误select a,b,sum(x) from (select a,b,'1' as x from aaaunion allselect a,b,'-1' as x from bbb)group by a,b改成下面这样还是同样报错:select a,b,sum(x) from (select a,b,'1' as x from aaa](/uploads/image/z/14123003-59-3.jpg?t=SQL2005+%E6%8A%A5%E9%94%99+%E5%9C%A8%E5%85%B3%E9%94%AE%E5%AD%97%27group%27+%E9%99%84%E8%BF%91%E6%9C%89%E8%AF%AD%E6%B3%95%E9%94%99%E8%AF%AFselect+a%2Cb%2Csum%28x%29+from+%28select+a%2Cb%2C%271%27+as+x+from+aaaunion+allselect+a%2Cb%2C%27-1%27+as+x+from+bbb%29group+by+a%2Cb%E6%94%B9%E6%88%90%E4%B8%8B%E9%9D%A2%E8%BF%99%E6%A0%B7%E8%BF%98%E6%98%AF%E5%90%8C%E6%A0%B7%E6%8A%A5%E9%94%99%EF%BC%9Aselect+a%2Cb%2Csum%28x%29+from+%28select+a%2Cb%2C%271%27+as+x+from+aaa)
SQL2005 报错 在关键字'group' 附近有语法错误select a,b,sum(x) from (select a,b,'1' as x from aaaunion allselect a,b,'-1' as x from bbb)group by a,b改成下面这样还是同样报错:select a,b,sum(x) from (select a,b,'1' as x from aaa
SQL2005 报错 在关键字'group' 附近有语法错误
select a,b,sum(x) from (
select a,b,'1' as x from aaa
union all
select a,b,'-1' as x from bbb)
group by a,b
改成下面这样还是同样报错:
select a,b,sum(x) from (
select a,b,'1' as x from aaa
)
group by a,b
同样的语句我再oracle9中就能执行,在SQL2005中执行就报错,请问有什么问题?
SQL2005 报错 在关键字'group' 附近有语法错误select a,b,sum(x) from (select a,b,'1' as x from aaaunion allselect a,b,'-1' as x from bbb)group by a,b改成下面这样还是同样报错:select a,b,sum(x) from (select a,b,'1' as x from aaa
select a,b,sum(x) from (
select a,b,'1' as x from aaa
union all
select a,b,'-1' as x from bbb) xx --注意看这里 多了一个别名xx
group by a,b
改成这样 为 from 后面的子查询指定一个名字 这里用的xx 你可以自己改一个