加入SQL中的第一行应该与简单地加入内部选择
一样简单select so_nbr, sod_line last_line
from so_mstr
join sod_det on sod_det.rowid = (select top 1 sod_det.rowid
from sod_det
where sod_nbr = so_nbr
order by sod_line desc) x
where so_ord_date > curdate() - 60
不幸的是,我得到了:Error code -20302, SQL state HY000: [DataDirect][OpenEdge JDBC Driver][OpenEdge] TOP clause used in unsupported context. (13694)
注意,我被困在OE10.1C上,无法升级。
答案 0 :(得分:1)
OpenEdge 11.2增加了对
OFFSET
andFETCH
clauses的支持 到SQLSELECT
查询;低于11.2的OpenEdge版本没有 支持OFFSET
/FETCH
。来自11.2 product documentation " SQL参考"文件:
The OFFSET clause specifies the number of rows to skip, before starting to return rows from the query expression. The FETCH clause specifies the number of rows to return, after processing the OFFSET clause.
值得注意的是,
TOP
和OFFSET
/FETCH
条款是 互斥 -TOP
不能在使用的查询中使用OFFSET
或FETCH
。
试试这个
SELECT so_nbr,sod_line As last_line
FROM so_mstr
JOIN sod_det ON sod_det.rowid = (SELECT sod_det.rowid
FROM sod_det WHERE sod_nbr = so_nbr
ORDER BY sod_line Desc
FETCH FIRST 1 ROWS ONLY) x
WHERE so_ord_date > curdate() - 60