I will try to formulate my problem precisely enough so someone can hopefully help me. Putting together some dummy_data would require time that I haven't actually got, but I'd do it if necessary, of course.
- I have personell data: Every emp has a Nr. and a "personell_unit" he belongs to.
- Due to my SQL_SELECT out of two DB tables, each employee ends up with n records:
- one where he belongs to "PU" 1 - this branch (level_1/ top-level)
- one where he belongs to PU 12 - this plant (there are two plants/halls to this branch)
- one where he belongs to PU 125 - one area in the plant
- one where he belongs to PU 1253 - early_shift (level_4)
- There might even be more.
- In my script, I actually have a max() fct. at one point, so this emp should remain with only one record as belonging to PU 1253.
=> To enable managers to see the combined figures for both shifts of one area, I have generated a mapping table where all PU-values are assigned the same "bigger_area", so when the user selects that, he sees all PU-codes assigned to that.
<=> My problem is now such that when I select one plant, then I can select any of the "bigger_areas" in that plant - and in that list, there is one PU-value (say, 125, to stick with that example) - that should not be there because the max() function should actually throw it out and keep only PU 1253
The numbers of course are different, this was just an example for the structure of my problem.
I will attach a txt file with the two LOAD statements where my problem lies.
Thanks a lot!
P.S.: Strangely, when I look at the nr_of_rows, the table in the second LOAD statement does get reduced by a few records, so something is happening - but I'm not sure what...