我是SQL语言的初学者(既不是Oracle也不是Access),我正在尝试将此Oracle SQL转换为MS Access SQL代码,但它失败并出现以下错误:
SQL> select
2 o.item,
3 o.qty ord_qty,
4 i.loc,
5 i.purch,
6 i.qty loc_qty,
7 sum(i.qty) over (
8 partition by i.item
9 order by i.purch, i.loc
10 rows between unbounded preceding and current row
11 ) sum_qty
12 from orderline o
13 join inventory i
14 on i.item = o.item
15 where o.ordno = :pick_order
16 order by
17 o.item,
18 i.purch,
19 i.loc;
有什么想法吗?
Oracle SQL
SELECT o.item, o.qty AS ord_qty, i.Loc, i.purch, i.qty AS loc_qty, sum(i.qty) over (partition by i.item rows between unbounded preceding and current row) AS sum_qty
FROM orderline AS o INNER JOIN inventory AS i ON o.item = i.item
WHERE (((o.ordno)=1))
ORDER BY o.item, i.purch, i.Loc;
MS Access SQL
{{1}}
答案 0 :(得分:0)
您可以使用相关子查询执行所需操作。我最好的猜测是:
SELECT o.item, o.qty AS ord_qty, i.Loc, i.purch, i.qty AS loc_qty,
(SELECT SUM(i2.qty)
FROM orderline o2 INNER JOIN
inventory as i2
ON o2.item = i2.item
WHERE o2.ordno = 0.orderno AND
i2.item = i.item AND
(i2.purch < i.purch or
i2.purch = i.purch and i2.loc = i.loc
)
) as sum_qty
FROM orderline AS o INNER JOIN
inventory AS i
ON o.item = i.item
WHERE o.ordno = 1
ORDER BY o.item, i.purch, i.Loc;
答案 1 :(得分:0)
正如其他一些人提到的,MS Access 不支持窗口函数