Skip to content
Advertisement

Missing records in a -6 table matrix

i would be grateful for any help in solving the problem below. I’ve restated the problem following a request for some data

I have the following sql tables

  1. qual = List of qualification codes (qualcode, description) e.g.

  2. labor = List of labor codes (laborcode, name)

  3. craft = List of craft codes (craft, desc)

  4. laborcraft = the craft attached to each labor code (laborcode, craft)

  5. qualcraft = qualifications relevant to each craft (qualcode, craft)

  6. laborqual = actual qualifications of each labor id (laborcode, qualcode)

Each Qualification code may be relevant for one or many crafts, Each labor code has a single craft

From the data in table 5 above you can see that qualification HSE-03 is relevant for the PLUM craft and HSE-02 is relevant for the ELEC craft

However from table 6 (actual qualifications) we can see that

  • Mark Twain is a PLUM craft but does not possess the HSE-03 qualification
  • Jane Smith is an ELEC but does not possess the HSE-02 qualification.

I need to identify all the qualifications that SHOULD be held by each labor code but ARE NOT. the results should look like

I don’t mind if labor codes have other qualifications that they don’t need to have for example

I just need to know where we’re missing the relevant qualifications

Thanks for any help

Advertisement

Answer

You could join laborcraft and qualcraft, and use not exists to flter on “missing” rows in laborqual:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement