Neoview SQL Reference Manual (R2.5)
FROM orders o, odetail d
WHERE o.ordernum=d.ordernum
SEQUENCE BY o.order_date, o.ordernum, d.partnum
ORDER BY o.order_date, o.ordernum, d.partnum;
Order/Num MCOUNT Part/Num Order/Date
AMOUNT ORDER_TOTAL TOTAL_SALES
---------- ----------- -------- ----------
---------- -------------- --------------
100250 1 244 2008-01-23
14000.00 14000.00 14000.00
100250 2 5103 2008-01-23
4000.00 18000.00 18000.00
100250 3 6500 2008-01-23
950.00 18950.00 18950.00
200300 1 244 2008-02-06
28000.00 28000.00 46950.00
200300 2 2001 2008-02-06
10000.00 38000.00 56950.00
200300 3 2002 2008-02-06
14000.00 52000.00 70950.00
... ... ... ...
800660 18 7102 2008-10-09
1650.00 187360.00 1113295.00
800660 19 7301 2008-10-09
5100.00 192460.00 1118395.00
--- 69 row(s) selected.
Note that, for example, for order number 200300, the ORDER_TOTAL is a moving sum
within the order date 2008-02-06, and the TOTAL_SALES is a running sum for all orders.
The current window for the moving sum is defined as ROWS SINCE
(THIS(o.ordernum)<>o.ordernum), which restricts the ORDER_TOTAL to the current order
number.
• Show the amount of time between orders by calculating the interval between two dates:
SELECT RUNNINGCOUNT(*),o.order_date,DIFF1(o.order_date)
FROM orders o
SEQUENCE BY o.order_date, o.ordernum
ORDER BY o.order_date, o.ordernum ;
(EXPR) Order/Date (EXPR)
-------------------- ---------- -------------
1 2008-01-23 ?
2 2008-02-06 14
3 2008-02-17 11
4 2008-03-03 14
5 2008-03-19 16
6 2008-03-19 0
7 2008-03-27 8
8 2008-04-10 14
9 2008-04-20 10
10 2008-05-12 22
11 2008-06-01 20
12 2008-07-21 50
13 2008-10-09 80
--- 13 row(s) selected.
328 SQL Clauses