SELECT c.orderid, b.sum_qty
FROM vw_order_list c CROSS JOIN
(SELECT SUM(psi_stock_in.qty) AS sum_qty
FROM psi_stock_in
WHERE psi_stock_in.itemcode = c.itemcode) b
总是弹出错误:
列前缀 'c' 与查询中所用的表名或别名不匹配
分享到:
------解决方案--------------------
SELECT c.orderid, b.sum_qty
FROM vw_order_list c CROSS JOIN
(SELECT SUM(psi_stock_in.qty) AS sum_qty
FROM psi_stock_in
) b
on b.psi_stock_in.itemcode = c.itemcode ------解决方案--------------------
SELECT c.orderid, b.sum_qty
FROM vw_order_list c CROSS JOIN
(SELECT SUM(psi_stock_in.qty) AS sum_qty
FROM psi_stock_in
) b
where b.psi_stock_in.itemcode = c.itemcode ------解决方案--------------------
SELECT c.orderid, b.sum_qty
FROM vw_order_list c CROSS JOIN
(SELECT itemcode,SUM(qty) AS sum_qty
FROM psi_stock_in
group by itemcode
) b
where b.itemcode = c.itemcode