伙计,此查询出了什么问题,我在下面的DB2 LUW中遇到错误。
[42703] [-206]“ d.sales”在使用上下文中无效。SQLCODE = -206,SQLSTATE = 42703,DRIVER = 4.23.42 [56098] [-727]错误在隐式系统操作类型“ 2”期间发生。返回的错误信息包括SQLCODE“ -206”,SQLSTATE“ 42703”和消息令牌“ d.sales”。.SQLCODE = -727,SQLSTATE = 56098,DRIVER = 4.23.42
SELECT listagg(e.name,';'), e.address,d.sales
FROM emp e
JOIN (
SELECT distinct sales, org
FROM sales s
JOIN address a ON S.ID = a.id
) d ON d.salesid = e.salesid
答案 0 :(得分:0)
查看您的查询:
SELECT listagg(e.name,';'), e.address,d.sales
FROM emp e
JOIN (SELECT distinct sales, org -- you need to add salesid to your columns set
FROM sales s
JOIN address a ON S.ID = a.id
) d ON d.salesid = e.salesid
您忘记在子查询salesid
中选择d
您需要添加s.salesid
或a.salesid
答案 1 :(得分:0)
显然我做了一个不好的例子,因为我无法通过实际查询。我想你们都没错,它缺少专栏。