IntervalMatch
IntervalMatch 前置詞可用來建立一個表格,比對離散數值與一個或多個數值間隔,並選擇性地比對一或數個其他索引鍵的值。
Syntax:
IntervalMatch (matchfield)(loadstatement | selectstatement )
IntervalMatch (matchfield,keyfield1 [ , keyfield2, ... keyfield5 ] ) (loadstatement | selectstatement )
間隔可能會重疊,所以離散值會連結到所有符合的間隔。
延伸的
為了避免忽略到未定義的間隔限制,可能必須允許
Arguments:
引數 | 描述 |
---|---|
|
包含離散數值的欄位,這些離散數值將連結至間隔。 |
|
包含其他屬性的欄位,其他屬性將在轉換中進行比對。 |
|
必須產生表格,其中第一個欄位包含每一個間隔的下限,第二個欄位包含每一個間隔的上限,在使用索引鍵配對時,第三個和任何後續欄位都包含 IntervalMatch 陳述式中呈現的索引鍵欄位。間隔一定是封閉的,也就是說,結束點是包括在間隔內。非數值的限制會使得間隔被忽略 (未定義)。 |
Example 1:
在下方的兩個表格中,第一個表格定義不同順序產生的開始和結束時間。第二個表格列出多個離散事件。透過 IntervalMatch 前置詞,可以按照邏輯順序連接兩個表格,以找出受干擾影響的順序,以及哪個位移處理哪些順序。
LOAD * Inline [
Time, Event, Comment
00:00, 0, Start of shift 1
01:18, 1, Line stop
02:23, 2, Line restart 50%
04:15, 3, Line speed 100%
08:00, 4, Start of shift 2
11:43, 5, End of production
];
OrderLog:
LOAD * INLINE [
Start, End, Order
01:00, 03:35, A
02:30, 07:58, B
03:04, 10:27, C
07:23, 11:43, D
];
//Link the field Time to the time intervals defined by the fields Start and End.
Inner Join IntervalMatch ( Time )
LOAD Start, End
Resident OrderLog;
結果:
表格 OrderLog 現在包含其他資料行:Time。還會展開記錄數目。
Time | Start | End | Order |
---|---|---|---|
00:00 |
- | - | - |
01:18 | 01:00 | 03:35 | A |
02:23 | 01:00 | 03:35 | A |
04:15 | 02:30 | 07:58 | B |
04:15 | 03:04 | 10:27 | C |
08:00 | 03:04 | 10:27 | C |
08:00 | 07:23 | 11:43 | D |
11:43 | 07:23 |
11:43 |
D |
Example 2: (使用
與上述範例相同,新增 ProductionLine 作為索引鍵欄位。
結果:
現可建立如下的表格方塊:
ProductionLine | Time | Event | Comment | Order | Start | End |
---|---|---|---|---|---|---|
P1 |
00:00 |
0 | Start of shift 1 | - | - | - |
P2 | 01:00 | 0 | Start of shift 1 | - | - | - |
P1 | 01:18 | 1 | Line stop | A | 01:00 | 03:35 |
P1 | 02:23 | 2 | Line restart 50% | A | 01:00 | 03:35 |
P1 | 04:15 | 3 | Line speed 100% | B | 02:30 | 07:58 |
P1 | 04:15 | 3 | Line speed 100% | C | 03:04 | 10:27 |
P1 | 08:00 | 4 | Start of shift 2 | C | 03:04 | 10:27 |
P2 | 09:00 | 4 | Start of shift 2 | D | 07:23 | 11:43 |
P1 | 11:43 | 5 | End of production | - | - | - |
P2 | 11:43 | 5 | End of production | D | 07:23 | 11:43 |