Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have 2 tables of data. 1 contains transaction data and the other has how many hours were worked for a given date and shift. I want to get the number of hours for the day merged with the transaction data. The issue I have is the hours gets duplicated for every transaction. I get 8 hours for each record for the day/shift. I only want to load the first time I see a date/shift. How can this be accomplished?
@dthornburg one way is like below
T1:
LOAD [Trans Date],
Shift,
[Wo Nbr],
Qty
FROM TableA;
left join(T1)
LOAD [Trans Date],
Shift,
Hours
FROM TableB;
Final:
LOAD [Trans Date],
Shift,
[Wo Nbr],
Qty,
if(([Trans Date]=previous([Trans Date]) and Shift<>previous(Shift)) or
[Trans Date]<>previous([Trans Date]),Hours,null()) as Hours
resident T1
order by [Trans Date],Shift,[Wo Nbr];
drop table T1;