7.2 区间查找

SQL

SELECT *
FROM Orders
WHERE OrderDate>='2021-12-29' and OrderDate<='2021-12-31'

SPL

对于数值、日期类型的字段,常常会用到区间查找。凡是需要用到区间查找的字段,只能使用排序索引。

A
1 >st=date(“2021-12-29”), et=date(“2021-12-31”), start=days@o(st), end=days@o(et)
2 =file(“Orders.ctx”).open()
3 =A2.index(file(“Orders.ctx__OrderDate”);OrderDate)
4 =A2.icursor(;OrderDate>=start && OrderDate<=end; file(“Orders.ctx__OrderDate”)).fetch()
5 =A2.close()