Oracle SQL子查询错误

qing zhangqing

我试图向左连接表编写子查询,但是出现错误,需要帮助以找出我的错误,谢谢。

select IT.*,
(select  firstname,lastname,sum(cost) as 2016_cost,agencyname
from sheet1
group by firstname,lastname,agencyname as aa)
from IT
left join aa on IT.lastname=aa.lastname,IT.firstname=aa.lastname
亚伦·迪茨(Aaron Dietz)

看起来您想要这样:

SELECT IT.*, aa.firstname, aa.lastname, aa.2016_cost, aa.agencyname
FROM IT
LEFT JOIN (SELECT firstname, lastname, sum(cost) as 2016_cost, agencyname
           FROM sheet1
           GROUP BY firstname, lastname, agencyname
          ) as aa on IT.lastname = aa.lastname
                 and IT.firstname = aa.lastname

您代码中的子查询位于中SELECT,您将其中放置列级子查询。您似乎想要一个表子查询或派生表,该表应该在FROM/JOIN列表中。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章