Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In SQL I have 1 table, and when i do this SQL i get the result i need.
"SELECT t1._KeyID,
t1._Tmp_TIME,
t1._TmpID,
sum(q1.FLAG) as xSUM
FROM Table1 t1
LEFT JOIN Table1 t2 on t2._KeyID = t1._KeyID
WHERE (t2._Tmp_TIME between t1._Tmp_TIME and t1._Tmp_END_TIME
AND t1._Tmp_IDX <> t2._Tmp_IDX)
GROUP BY t1._KeyID, t1._Tmp_TIME,t1._TmpID"
Table1:
| _KeyID | _TmpID | _Tmp_IDX | _Tmp_TIME | _Tmp_END_TIME | FLAG |
| 22062019|10026|411458 | 114040943 | 13746 | 08:36:20.0000000 | 08:37:20.0000000 | 1 |
| 22062019|10026|411458 | 114040944 | 13746 | 08:36:21.0000000 | 08:37:21.0000000 | 1 |
| 22062019|10026|411458 | 114040945 | 13746 | 08:36:23.0000000 | 08:37:23.0000000 | 1 |
| 22062019|10026|411458 | 114040932 | 13746 | 08:36:24.0000000 | 08:37:24.0000000 | 1 |
| 22062019|10026|411458 | 114040643 | 13746 | 08:36:26.0000000 | 08:37:26.0000000 | 1 |
| 22062019|10026|411458 | 114040644 | 13746 | 08:36:26.0000000 | 08:37:26.0000000 | 1 |
| 22062019|10026|411458 | 114040645 | 13900 | 08:36:28.0000000 | 08:37:28.0000000 | 1 |
| 22062019|10026|411458 | 114040646 | 13900 | 08:36:30.0000000 | 08:37:30.0000000 | 1 |
| 22062019|10026|411458 | 114040647 | 13577 | 08:36:32.0000000 | 08:37:32.0000000 | 1 |
| 22062019|10026|411458 | 114040648 | 13726 | 08:36:37.0000000 | 08:37:37.0000000 | 1 |
Result of SQL:
| _KeyID | _Tmp_TIME | _TmpID | xSUM |
| 22062019|10026|411458 | 08:36:20.0000000 | 114040943 | 4 |
| 22062019|10026|411458 | 08:36:21.0000000 | 114040944 | 4 |
| 22062019|10026|411458 | 08:36:23.0000000 | 114040945 | 4 |
| 22062019|10026|411458 | 08:36:24.0000000 | 114040932 | 4 |
| 22062019|10026|411458 | 08:36:26.0000000 | 114040643 | 4 |
| 22062019|10026|411458 | 08:36:26.0000000 | 114040644 | 4 |
| 22062019|10026|411458 | 08:36:28.0000000 | 114040645 | 2 |
| 22062019|10026|411458 | 08:36:30.0000000 | 114040646 | 2 |
The Table1 is easy to enough to create as a resident table in LOAD script, but my mind is tired and fresh out of ideas to in converting the SQL Select to LOAD SCRIPT.
So how do i do this in the LOAD SCRIPT?
Note: The data i'm normally loads comes from QVDs