在插入查询中获取错误我如何... [英] Getting error in the insert queryHow do I...

查看:68
本文介绍了在插入查询中获取错误我如何...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

INSERT INTO abc(x,y,MARK,z)

SELECT tx,ty,max(t.Final_Grade),newid()

FROM#TEMP2 t

哪里不存在

(从mk中选择x,y

其中mk.y = ty

和mk .x = tx)

group by tx,ty



error ...

Column'#TEMP2 .y'在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。

INSERT INTO abc(x,y,MARK,z)
SELECT t.x, t.y, max(t.Final_Grade), newid()
FROM #TEMP2 t
WHERE not exists
(select x, y from mk
where mk.y=t.y
and mk.x=t.x )
group by t.x,t.y

error ...
Column '#TEMP2.y' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

推荐答案

内部查询中未定义Temp2 。所以当你在内部查询中过滤temp2时会出现错误。

这可以用JOIN编写,这就是你应该尝试的。
Temp2 is not defined in the inner query. So when you filter on temp2 in the inner query there is an error.
This can be written with a JOIN and that is what you should try.


这篇关于在插入查询中获取错误我如何...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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