-1

我试图从同一个表中根据不同的条件提取两个不同的值,并且在同一个表的左连接中它无法识别 SELECT 语句。

错误如下:

Dynamic SQL Error
SQL error code = -104
Token unknown - line 7, char -1
SELECT.

SQL 语句:

SELECT
b.dept,b.typ,c.brand,c.style,c.ext,c.description,
max(c.price),max(c.last_cost),sum(c.quan) "TOTAL INV",D.QUAN "WEB INV"
FROM
invt c
left outer join (
    SELECT dept,typ,brand,style,ext,description,sum(quan) as d.quan
    FROM invt WHERE store in ('997')
    group by dept,typ,brand,style,ext,description) d 
on (b.store = d.store and b.style = d.style and b.brand = d.brand)
LEFT OUTER JOIN
sku b
on c.style = b.style and c.brand = b.brand
where c.quan <> 0 or c.ord <> 0
GROUP BY
b.dept,b.typ,c.brand,c.style,c.ext,c.description
4

1 回答 1

1

尝试更改此行:

SELECT dept,typ,brand,style,ext,description,sum(quan) as d.quan

对此:

SELECT store,dept,typ,brand,style,ext,description,sum(quan) as quan

您在这里不需要d别名。

更新:

正如@Jeremy Holovacs 提到的,您似乎也在使用 d.store 进行连接,但它在您的子查询中不存在。

于 2012-06-06T20:30:06.107 回答