Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have this load script:
generating this table :
BusNumber | FromStation | ToStation | Departure | Arrival | Transit |
201 | A | B | 10:00 | 12:00 | None |
201 | A | C | 10:00 | 18:00 | B |
201 | B | C | 14:00 | 18:00 | None |
I would like to add additional lines and columns, based on this logic:
- For each line that had a Transit non equal to None (i.e. Line 2 with Transit B)
The end result table:
Bus Number | FromStation | ToStation | Departure | Arrival | Transit | FromTransit Station | ToTransit Station | Transit Departure | Transit | |
201 | A | B | 10:00 | 12:00 | None | |||||
201 | A | C | 10:00 | 18:00 | B | A | B | 10:00 | 12:00 | Updated line, new columns retrieved from Line 1 |
201 | A | C | 10:00 | 18:00 | B | B | C | 14:00 | 18:00 | New line, new columns retrieved from Line 5 |
201 | B | C | 14:00 | 18:00 | None |
Many thanks in advance for your help,
Annick
One way to do this
TableA: LOAD * INLINE [ BusNumber, FromStation, ToStation, Departure, Arrival, Transit 201, A, C, 10:00, 18:00, B 201, A, B, 10:00, 12:00, None 201, B, C, 14:00, 18:00, None ]; FinalTable: NoConcatenate LOAD * Resident TableA Where Transit = 'None'; TempTable: NoConcatenate LOAD * Resident TableA Where Transit <> 'None'; Left Join (TempTable) LOAD ToStation as Transit, FromStation as FromTransitStation, ToStation as ToTransitStation, Departure as TransitDeparture, Arrival as TransitArrival Resident TableA; Concatenate (FinalTable) LOAD * Resident TempTable; DROP Table TempTable; TempTable: NoConcatenate LOAD * Resident TableA Where Transit <> 'None'; Left Join (TempTable) LOAD FromStation as Transit, FromStation as FromTransitStation, ToStation as ToTransitStation, Departure as TransitDeparture, Arrival as TransitArrival Resident TableA; Concatenate (FinalTable) LOAD * Resident TempTable; DROP Table TempTable; DROP Table TableA;
One way to do this
TableA: LOAD * INLINE [ BusNumber, FromStation, ToStation, Departure, Arrival, Transit 201, A, C, 10:00, 18:00, B 201, A, B, 10:00, 12:00, None 201, B, C, 14:00, 18:00, None ]; FinalTable: NoConcatenate LOAD * Resident TableA Where Transit = 'None'; TempTable: NoConcatenate LOAD * Resident TableA Where Transit <> 'None'; Left Join (TempTable) LOAD ToStation as Transit, FromStation as FromTransitStation, ToStation as ToTransitStation, Departure as TransitDeparture, Arrival as TransitArrival Resident TableA; Concatenate (FinalTable) LOAD * Resident TempTable; DROP Table TempTable; TempTable: NoConcatenate LOAD * Resident TableA Where Transit <> 'None'; Left Join (TempTable) LOAD FromStation as Transit, FromStation as FromTransitStation, ToStation as ToTransitStation, Departure as TransitDeparture, Arrival as TransitArrival Resident TableA; Concatenate (FinalTable) LOAD * Resident TempTable; DROP Table TempTable; DROP Table TableA;